Hello. I have a fairly straightforward code:
public class Battle_Manager : MonoBehaviour
{
private HeroStats _Cube;
void Awake()
{
_Cube = GameObject.Find ("Cube").GetComponent<HeroStats>() as HeroStats;
_Cube.Hero = GameObject.Find("Cube");
}
This much works. It’s just when I add in things such as…
public class Battle_Manager : MonoBehaviour
{
private HeroStats _Cube;
void Awake()
{
_Cube = GameObject.Find ("Cube").GetComponent<HeroStats>() as HeroStats;
_Cube.Hero = GameObject.Find("Cube");
_Cube.Base.Health = 100;
}
}
That I experience problems. I created a reference to my BaseStat class, my ModifiedStat class, and my Equipment class in the HeroStats class, and it seems that it won’t allow me to pull from it without getting a NullReferenceException.
Also, I’ve tried both using GetComponent<>() and GetComponent<>() as x… still can’t access anything because it’s not “assigned” to the object.
Thanks for any help!