NullReferenceException error - help?

Hi,

I’m working on a headtracking script at the moment, and struggling a little, but have just hit a problem I don’t understand not related to the headtracking itself.

Here is the code:

var xRange : float = 0.8;
var yRange : float = 0.4;
var left : float = xRange/-2;
var right : float = xRange/2;
var top : float = yRange/2;
var bottom : float = yRange/-2;

var shiftAmount : float = 5;
private var newX;
private var newY;

function Update () {
var headtrack = GameObject.Find("Head");
var left = xRange/-2;
left += headtrack.Transform.x

It gives the error : NullReferenceException: Object reference not set to an instance of an object
I tried originally setting up a

var headtrack : Transform;

before the Update function, and then dragging the relevant transform into the inspector, but had the same issue and error code when trying to access headtrack.Transform.x in the Update, for example.
Anyone know what I’m doing wrong?
Thank you so much,
Steve

Ok, figured it out. Still such a rookie. Turns out you just need a blank, empty script attached to the other object. Simple.