Answer the question
In order to leave comments, you need to log in
How to fix the NullReferenceException error when accessing a variable from another script?
I make 2 hostile creatures, one attacker, the other scout.
When the scout sees the player, it increases the variable by 1, and the attacker, if this variable becomes greater than 0, starts walking towards the player. But when I access this variable, I get a NullReferenceException error.
if (GetComponent<AI_DronRazved>().call >= 1 )
{
angry = true;
chill = false;
goBack = false;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question