- Home /
NullReferenceException: Object reference not set to an instance of an object
Original post has been removed.
Have you left out any comments or additional lines at the beginning of the script? It tells us that Line 40 is where the error occurs, but Line 40 is a line break.
Sorry i just edited like 2 comments out but the error is at 37 where it shows line:
player.GetComponent<HeroCtrl_$$anonymous$$odded>().enabled = false;
Answer by morgan23 · Jun 20, 2014 at 12:59 AM
Try changing player too public then give it player in inspector. That error mean's you haven't assigned something which looks too be player. Also try if(player! = null){
} before you get the player 1 of these should work I think.
That seems to be the case now I think about it. I try to geenrally stay away from global references like that because I intend to allow multiplayer unless it doesnt affect implementation that dramatically but correct me if im wrong
Your answer
Follow this Question
Related Questions
Object reference not set to an instance of an object 0 Answers
C# Null Object Reference - Driving me mad! 1 Answer
Null reference.. 2 Answers
Object Pool object reference is null? 1 Answer
A node in a childnode? 1 Answer