I am having trouble with the last few lines of this code, I will post the error (all 4 are the same and point to the same code) and code. It is attached to a gameobjedct with a rigidbody and the mouselook script. It is supposed to move forward and backward in midair.
Here is the code
private var pilot : Rigidbody; var thrustForce = 3;
var invertPitch : boolean = true; var invertYaw : boolean = false; var sensitivity : float = 1000;
function Update () {
if (Input.GetKeyDown("w"))
SetThrust(5); // other ifs here
if (Input.GetKeyUp("w")) {
SetThrust(0);
}
if (Input.GetKeyDown("s")) {
SetThrust(-3);
}
if (Input.GetKeyUp("s")) {
SetThrust(0);
}
}
function SetThrust ( thrustForce : int) {
pilot.constantForce.relativeForce = Vector3.forward *
thrustForce * sensitivity;
}
Here is the error, It occurs whenever you press w or s down or release it.
NullReferenceException
moonflight.SetThrust (Int32
thrustForce) (at
Assets\moonflight.js:37)
moonflight.Update () (at
Assets\moonflight.js:24)