CharacterController NullReferenceException dispite attached to object


I am writing a movement script using CharacterController. I have a characterController component attached to my object, but, it keeps returning a NullReferenceException. I have tried creating a new object as well as importing one of the example objects, but nothing seems to work. Below is all the code in the script that mentions the CharacterController.

private var character : CharacterController;

character = GetComponent(CharacterController);

if(this.transform.position != standardPos)
		var target : Vector3 = standardPos;
        target.y = transform.position.y; // keep waypoint at character's height
        var moveDirection : Vector3 =  target - transform.position;
        if(moveDirection.magnitude < 1)
            transform.position = target; // force character to waypoint position



Place that code in the Update function and it will work :slight_smile: