UnassignedReferenceException when its already assigned


ive written a script and it says that one of my variables has not been asigned??? very confused because its assigned and the script still works fine its just this error keeps coming up.
sing UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour {

	// Use this for initialization
	CharacterController charController;
	Animator Anim;

	public GameObject camera;
	public float Sensitivity = 5;
	public float CameraSmooth = 0.1f;

	public float xRotationCam;
	public float yRotationCam;

	float camXrotation;
	float camYrotation;

	void Start () {
		Anim = GetComponent<Animator>();
		charController = GetComponent<CharacterController>();
	// Update is called once per frame
	void Update () {

		v = Input.GetAxis("Vertical"); // gets your mouse inputs
		h = Input.GetAxis("Horizontal");

		//****CAMERA MOVEMENT****\\
		yRotationCam -= Input.GetAxis("Mouse Y") * Sensitivity;
		xRotationCam += Input.GetAxis("Mouse X") * Sensitivity;

		yRotationCam = Mathf.Clamp(yRotationCam, -90, 90);

		camYrotation = Mathf.Lerp(camYrotation, yRotationCam, CameraSmooth);
		camXrotation = Mathf.Lerp(camXrotation, xRotationCam, CameraSmooth);
		camera.transform.localRotation = Quaternion.Euler(camYrotation, 0, 0);//error on this line
		transform.rotation = Quaternion.Euler(0, camXrotation, 0);


ive shortened my script to make it easier to read (Hopefully)

UnassignedReferenceException: The variable camera of ‘PlayerController’ has not been assigned.
You probably need to assign the camera variable of the PlayerController script in the inspector.
PlayerController.Update () (at Assets/_A Player/Scripts/PlayerController.cs:129)

thanks ~Scott

hey i only have one of these scripts in my project. ive fixed it ive just made a new scripts and only put the camera movement stuff in it thanks anyway :wink: