Help a n00b out, NullReferenceExeption

Hi all!
I’m trying to build a racegame on android /iOS…

I got a first test buld ready to render, controls are working fine with android remote… I’ve used the scripts from the car tutorial, and tweaked them a little bit…

So, in the editor everything runs fine. It however won’t build due to the followoing compiler error±

It refers to this part of the script (I think)…

function Update()
{
var relativeVelocity : Vector3 = transform.InverseTransformDirection(rigidbody.velocity);

GetInput();

Check_If_Car_Is_Flipped();

UpdateWheelGraphics(relativeVelocity);

UpdateGear(relativeVelocity);
}

Now, I´m not too bad with scripting, but this one goes over my head…I see it has something to do with the rotation of the wheels, but what’s wrong? :expressionless: I´ve tried for a couple of hours now, cutting and pasting, and still didnt find a solution… The worst thing is it runs great in the editor, so after a days hard work, its kinda like a kick in the nuts :rage:

Anyboyd any idea what this error is, and how to fix it?

Many thanks in advance! :slight_smile:
Thomas

What is relativeVelocity?
What is in line 378?

ANother thing…

var relativeVelocity : Vector3 = transform.InverseTransformDirection(rigidbody.[b]velo city[/b]);

Is velocity or velo city? :stuck_out_tongue:

Hi!

Line 376 to 379:

Has to do with “Code to handle skidmark drawing”…

It is velocity, I don’t know why there’s a space between there… It’s not there when I edit the post… ? :S

As far as what relativevelocity is… It is some measurement of speed I suspect, wich then translates to the wheels turning…

“var relativeVelocity : Vector3 = transform.InverseTransformDirection(rigidbody.velocity);”

Is the first instance of relativeVelocity relativeVelocity…

The sound variable is set from a SoundController component (ie, the SoundController.js script) which should also be added to the object with the Car.js script. Drag SoundController.js onto the car object and the error should disappear.

Ahhh, yes it works! So that’s where it went wrong… The nullreference was about there not being any sound it could play, and the sounds are relative to the wheel speed… Thanks!!