NullReferenceException: Object reference not set to an instance of an object

So frustrated with making my own charactercontrollers, I have decided to use the default 3rd person. I still have the construction worker attached since I started back from scratch and have yet to attach my model. I am getting this 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)

I need to fix this…

I have this line as line 129 in the ThirdPersonController script:

  var cameraTransform = Camera.main.transform;

My educated guess is that you replaced the tag on the main camera, or you deleted the main camera. The use of ‘Camera.main’ to access the camera only works if the camera is tagged as ‘MainCamera’.

1 Like