Hi, I have a script that handles my character’s health, and now Im trying to get a second script to access this value and display it on the script, here’s what I’ve got (and isnt working):
public class PlayerHealth : MonoBehaviour
{
public float health = 100f;
public float resetAfterDeathTime = 5f;
public AudioClip deathClip;
...
And here’s the GUI script:
using UnityEngine;
using System.Collections;
public class GUIscript : MonoBehaviour
{
private PlayerHealth playerHealth; //Reference to the playerHealth component.
void OnGUI () {
GUI.Box (new Rect (15,15,150,20), "Health: " + playerHealth.health);
}
}