Rigidbody Problem - Object reference not set

Hey guys, I have a little problem with my script where I cannot move the GameObject/Player because of the following error:

NullReferenceException: Object reference not set to an instance of an object
PlayerMovement.Update () (at Assets/Scripts/Character/PlayerMovement.js:14)

The problem only shows when the I am running the game, the problem is happening because I am using Unity 4 and the tutorial is an older version. This is the script I have written:

#pragma strict

var WalkAcceleration : float = 5;
var CameraObject : GameObject;

function Start () 
{

}

function Update () 
{
	//Rotation Y was made public in MouseLook script
	transform.rotation = Quaternion.Euler(0, CameraObject.GetComponent(MouseLook).rotationY, 0);
	
	rigidbody.AddRelativeForce(Input.GetAxis("Horizontal") * WalkAcceleration, 0, Input.GetAxis("Vertical") * WalkAcceleration);
	
}

Thanks for the help guys, really means a lot.

Did you remember to drag the camera object to CameraObject in the inspector?

–

Yeah, I have done that already, still can't figure it out :(

–

Thanks for all the help guys, I have sorted the problem out. I made an error in my MouseLook Script and BenProductions you was right :), thanks buddy

–

Please close the question then :)

–

That's the problem, I don't know how to :D

–

1 Answer

1

Does you camera have a MouseLook script attached?