- Home /
Duplicate Question
Stealth Tutorial: NullReferenceException with AlarmLight
I'm following the unity stealth tutorials, and running into a "nullreferenceexception: Object Reference not set to an instance of an object" when testing, at the end of chapter 2, lesson 4. pretty deep in, however the compiler highlights problems with a much earlier thread
See my code on pastebin, The line it highlights is line 23.
And here's a picture from the editor which is most likely relevant:
What did i do wrong, did i make the same mistake several times with other objects too? and what can i do to prevent this in future?
There are a gazillion questions asking about nullreferenceexceptions. FindGameObjectWithTag()
failed to find a game object, and your code assumes it did find something.
Follow this Question
Related Questions
Why does this happen to my capsule collider at runtime? 2 Answers
NullReferenceException 0 Answers
NullReferenceException: Object reference not set to an instance of an object ? 1 Answer
NullReferenceException: Object reference not set to an instance of an object 0 Answers
NullReferenceException: Object reference not set to an instance of an object 0 Answers