I created an object in a script and I’m trying to access that object from another script.
How can I do that? I tried myScriptRef.character.Health but it doesn’t work.
public class Character {
public int Health = 100;
}
public class MyScript : MonoBehaviour {
void Start() {
Character character = new Character();
}
}
public class MyOtherScript : MonoBehaviour {
public MyScript myScriptRef;
void Start() {
Debug.Log(myScriptRef.character.Health); // Doesn't work
}
}