- Home /
NullReferenceException: Object reference not set to an instance of an object HELP
im new to unity (no need to welcome)i learned already,but the only thing i cant stand is the NullReferenceException: Object reference not set to an instance of an object
here is the full error: NullReferenceException: Object reference not set to an instance of an object ThirdPersonController.UpdateSmoothedMovementDirection () (at Assets/Standard Assets/Character Controllers/Sources/Scripts/ThirdPersonController.js:129) ThirdPersonController.Update () (at Assets/Standard Assets/Character Controllers/Sources/Scripts/ThirdPersonController.js:302)
im not good with errors,what im trying to do is make the character mmove,some said the camera but i made a camera and added,BUT HALP please
Answer by kilgore · Mar 29, 2014 at 07:50 PM
The error is telling you that there is a problem at lines 129 of ThirdPersonController. If we crack open the script and look at that line we see a reference to the the Camera.main. Camera.main is a static variable that is set when a Camera is given the MainCamera tag. You can see that in the image below. There is probably not a camera in your scene with the MainCamera tag, so that means that the Camera.main variable is never set and you get a NullReferenceException
.
Your answer
Follow this Question
Related Questions
Object reference not set to an instance of an object 1 Answer
Accessing variable in another script? 2 Answers
Select and save object 1 Answer
use mouse click to pause/stop a transform rotate script on gameobject 1 Answer
How to highlight a box in a grid on mouse hover, action whenever clicked 0 Answers