I’m using JavaScript. I have a public variable called “playerLife” which is a float. It’s in a script called “Battle” and placed on an object named “Cube”. The error I’m getting is “An instance of type ‘Battle’ is required to access non static member ‘playerLife’.” How do I retrieve this variable in a separate script which is on a separate game object?
I’ve tried:
function Start() {
var yourLife: float = GameObject.Find("Cube").GetComponent(Battle.playerLife);
Debug.Log(yourLife);
}