NullReferenceException

I have “NullReferenceException: Object reference not set to an instance of an object Attacker.Awake () (at Assets/Scripts/Attacker.cs:13)” and “NullReferenceException: Object reference not set to an instance of an object Attacker.OnDestroy () (at Assets/Scripts/Attacker.cs:18)” problems. How can I solve these problems?

Hi,

NullReferenceException means that a reference (“link”) to an instance is missing. Double click on the error message to see to which line in your code it is referring. If you exposed a field in the Inspector, make sure that it’s not empty.

Did this help? :slight_smile:


See also:

It is not empty. I wrote everything. I even copied and pasted the all codes but i still have the same problem.
"
private void Awake()
{
FindObjectOfType().AttackerSpawned();
}
private void OnDestroy()
{
FindObjectOfType().AttackerKilled();
}
"
These are lines 13 and 18

Aahhaa! I solved it.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms