Script error help!


I was wondering why I get these errors from my script:


#pragma strict
private var X : float;
var offset : int;
var FollowCamera : boolean;

function Start ()
	X = Camera.main.transform.position.x;
function Update ()
		transform.position.x = (Camera.main.transform.position.x - X)/offset;
		} else {
		transform.position.x = (X - Camera.main.transform.position.x - X)/offset;

It appears that Camera.main is returning null, X will initialize to 0 and it’s not nullable. Make sure your camera is tagged “MainCamera”, also you can try replacing Camera.main.transform.position.x with Camera.current.transform.position.x, current get the current rendering camera, main will return a tagged camera tagged with “MainCamera”.