private var frontLeftTyre : Transform;
private var frontRightTyre : Transform;
private var backLeftTyre : Transform;
private var backRightTyre : Transform;
private var backLeftCollider : Wheel;
private var backRightCollider : Wheel;
private var frontLeftCollider : Wheel;
private var frontRightCollider : Wheel;
var frontWheelSteering = false;
var rearWheelSteering = false;
var frontWheelDrive = false;
var rearWheelDrive = false;
var minSteeringAngle = 0.00;
var maxSteeringAngle = 0.00;
var highSpeed = 0.00;
var motorMass = 1.00;
var motorDrag = 0.00;
var maxAcceleration = 0.00;
var maxMotorSpeed = 0.00;
var minTorque = 0.00;
var maxTorque = 0.00;
var centerOfMass : Vector3;
var steeringInput = 0.00;
var motorInput = 0.00;
var motorTorque = 0.00;
var motorAccel = 0.00;
var motorSpeed = 0.00;
var steeringAngle = 0.00;
function Start () {
transform.parent = null;
rigidbody.centerOfMass = centerOfMass;
frontLeftTyre = transform.Find("frontLeftTyre");
frontRightTyre = transform.Find("frontRightTyre");
backLeftTyre = transform.Find("backLeftTyre");
backRightTyre = transform.Find("backRightTyre");
**frontLeftCollider = frontLeftTyre.GetComponent(Wheel);
frontRightCollider = frontRightCollider.GetComponent(Wheel);
backLeftCollider = backLeftTyre.GetComponent(Wheel);
backRightCollider = backRightTyre.GetComponent(Wheel);
frontLeftCollider.Falcon With Pivots = this;
frontRightCollider.Falcon With Pivots = this;
backLeftCollider.Falcon With Pivots = this;
backRightCollider.Falcon With Pivots = this;**
if(frontWheelDrive) frontLeftCollider.driven = frontRightTyre.driven = true;
if(rearWheelDrive) backLeftCollider.driven = backkRightCollder.driven = true;**
}
function FixedUpdate ()
{
steeringInput = Input.GetAxis("Horizontal");
motorInput = Input.GetAxis("Vertical");
if(frontWheelSteering) frontLeftTyre.localRotation = frontRightTyre.localRotation = Quaternion.LookRotation(Vector3(steeringInput * (steeringAngle / 90), 0, 1 + (-1 * Mathf.Abs(steeringInput * (steeringAngle / 90))) ));
if(rearWheelSteering) backLeftTyre.localRotation = backRightTyre.localRotation = Quaternion.LookRotation(Vector3(-steeringInput * (steeringAngle / 90), 0, 1 + (-1 * Mathf.Abs(steeringInput * (steeringAngle / 90))) ));
if(frontWheelDrive || rearWheelDrive)
{
motorTorque = Mathf.Lerp(maxTorque / 30, minTorque / 30, motorSpeed / maxMotorSpeed) * Mathf.Abs(motorInput);
if(motorTorque < 1) motorTorque = 1;
motorAccel = Mathf.Lerp(maxAcceleration, 0, Mathf.Abs(motorSpeed) / maxMotorSpeed);
steeringAngle = Mathf.Lerp(maxSteeringAngle, minSteeringAngle, rigidbody.velocity.magnitude / highSpeed);
motorSpeed += motorInput * motorAccel / motorMass * Time.fixedDeltaTime;
if(frontWheelDrive)
{
frontLeftTyre.speed = frontRightTyre.speed = motorSpeed;
}
if(rearWheelDrive)
{
backLeftTyre.speed = backRightTyre.speed = motorSpeed;
}
motorSpeed += -motorSpeed * motorDrag / motorTorque * Time.fixedDeltaTime;
}
}
function AddForceOnMotor (force : float)
{
motorSpeed += force / motorTorque;
}
Update the errors are on line 51 - 54