- Home /
third person controller
the the third person controller of unity 3 has this problem:
NullReferenceException ThirdPersonController.UpdateSmoothedMovementDirection () (at Assets/Standard Assets/Character Controllers/Sources/Scripts/ThirdPersonController.js:130) ThirdPersonController.Update () (at Assets/Standard Assets/Character Controllers/Sources/Scripts/ThirdPersonController.js:304)
ON:
function UpdateSmoothedMovementDirection () { var cameraTransform = Camera.main.transform;
i'm already put my main camera on the ThirdPersonCamera script
Answer by Loius · Oct 02, 2010 at 10:58 PM
Camera.main is not something you put on something, it just exists.
You need to have a camera object enabled and tagged with "MainCamera" tag.
Answer by evilbob · Mar 29, 2011 at 02:59 AM
I had the same error in the FPS tutorial with lerpz (page 19 I think) and I fixed by selecting the "Near Camera" in the hierarchy window and in the Inspector window changing the tag to "Main Camera" in the drop down list. I was also getting several
NullReferenceException at (wrapper managed-to-native) UnityEngine.Component:get_transform ()
at FuelCellGlowLookAt.Update () [0x00000] in C:\Documents and Settings\Owner\My Documents\3DPlatformTutorialStart\Assets\Scripts\Misc\FuelCellGlowLookAt.js:7
Updating the main camera tag fixed this as well.
Thank you Vicenti