- Home /
The question is answered, right answer was accepted
NullReferenceException on ThirdPersonControlller
Hello. I have added a Third Person Controller on my character, and I did not edit the script.
Then I got a NullReferenceException, and it seemed to be on line 129.
Edited code on line 129:
var cameraTransform = Camera.mainCamera.transform;
Code on line 129 before edited:
var cameraTransform = Camera.main.transform;
I edited it to see if it would change if it was a problem with the main camera. However it kept giving me a NullReferenceException.
Do any of you coders have a solution to this?
If so, please answer!
Thanks!
No it got deleted. I made another one and called it $$anonymous$$ain Camera. with the space in between.
I cannot believe you asked a whole separate question just to ask "How do I add a tag" : http://answers.unity3d.com/questions/441349/how-to-give-camera-the-maincamera-tag.html
Have you heard of google ? : http://www.lmgtfy.com/?q=unity+tag
Answer by CrystalRain0329 · Apr 18, 2013 at 04:46 PM
Do you have a camera in your scene with the MainCamera tag? Camera.main will return null if you don't, or if it is disabled
Follow this Question
Related Questions
Can someone fix this coding? 1 Answer
problem with my simple script please help. 2 Answers
Do parent tags always affect children? 1 Answer
Adding y position? 4 Answers
How do I fix textures? 0 Answers