Hello,
I want to add health number on card object, but I don’t know how to make this text follow it. I want make that text attached to it, but I don’t know how to write it. My code:
using UnityEngine;
using System.Collections;
public class HealthScript : MonoBehaviour {
public int maxHealth = 10;
public int curHealth = 10;
void Start () {
}
void Update () {
AddjustCurrentHealth(0);
}
void OnGUI () {
GUI.Label (new Rect (20, 40, 50, 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;
}
}
I would appreciate any help/instructions.