Project Bölümünden Create > C# Script yapıyoruz ve içindekileri silip aşağıdaki kodları yapıştırıyoruz;
Kodlar
using UnityEngine;using System.Collections;
public class PlayerHealth : MonoBehaviour {
public int maxHealth = 100;
public int curHealth = 100;
public float healthBarLength;
// can bari bolum 1
void Start () {
healthBarLength = Screen.width / 2;
}
// can yukseltme alcaltma bolum son
void Update () {
AddjustCurrentHealth(0);
}
void OnGUI() {
GUI.Box(new Rect(10, 10, healthBarLength, 20 ), curHealth + "/" + maxHealth);
}
public void AddjustCurrentHealth(int adj) {
curHealth += adj;
if(curHealth < 0)
curHealth = 0;
if(curHealth > maxHealth)
curHealth = maxHealth;
if(maxHealth < 1)
maxHealth = 1;
healthBarLength = (Screen.width / 2) * (curHealth / (float)maxHealth);
}
} Son olarak bu scripti karakterimize atmamız yeterli oluyor play tuşuna bastığınızda sol tarafda can barınızı görebileceksiniz.
Tüm kodları ben yazdım emeği saygı lütfen.

eyw işime yaradı sağolasın
YanıtlaSilCan nasıl gidecek, anlatırmısın?
YanıtlaSilCan nasıl gidecek, anlatırmısın?
YanıtlaSil