I'm working on a game, where the player dumps trash from Trash cans into a Trash Truck. These Trash cans have a random chance of having a Racoon on top of them.
I have a script set up to detect when the player enters a Collider Trigger attached to the Racoon, which will cause it to play an animation and start attacking the player.
To do that, it needs to work with a racoon navigation component on a neighbouring object:
I'm trying to access the
RacoonNAVAI component on the
Racoon_Mover game object with this line:
racNav = transform.parent.parent.Find("Racoon Mover").gameObject.GetComponent<RacoonNAVAI>();
But it's throwing a null reference exception. How can I correctly get a reference to this component?