N
N
Nik Titor2021-08-03 18:00:35
Unity
Nik Titor, 2021-08-03 18:00:35

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

1 answer(s)
F
freeExec, 2021-08-03
@freeExec

How to fix "missing value" error, well I don't even know, can ensure the value exists before it is accessed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question