need help with simple problem

unity, javascript

hey guys, please help, this is a script for a racing game im making to control the car… my car is supposed to go forward, backwards, and turn both left and right well and it was working well but i must have messed something up because it wont turn left or right almost at all anymore. heres the code. any help is greatly appreciated :slight_smile:

#pragma strict
var wheelFL : WheelCollider;
var wheelFR : WheelCollider;
var wheelRL : WheelCollider;
var wheelRR : WheelCollider;
var wheelFLTrans : Transform;
var wheelFRTrans : Transform;
var wheelRLTrans : Transform;
var wheelRRTrans : Transform;
var maxTorque : float = 50;
function Start () {
rigidbody.centerOfMass.y = -0.10;
}

function FixedUpdate () {
wheelRR.motorTorque = maxTorque * Input.GetAxis("Vertical");
wheelRL.motorTorque = maxTorque * Input.GetAxis("Vertical");
wheelFL.motorTorque = maxTorque * Input.GetAxis("Horizontal");
wheelFR.motorTorque = maxTorque * Input.GetAxis("Horizontal");
}
function Update () {
wheelFLTrans.Rotate(wheelFL.rpm/60*360*Time.deltaTime,0,0);
wheelFRTrans.Rotate(wheelFL.rpm/60*360*Time.deltaTime,0,0);
wheelRLTrans.Rotate(wheelFL.rpm/60*360*Time.deltaTime,0,0);
wheelRRTrans.Rotate(wheelFL.rpm/60*360*Time.deltaTime,0,0);
}

I would guess, you need to change line 22 - 25, as they all are asking for the wheelFL.rpm. Maybe you need to change it in line 23 to wheelFR and so on? It’s not a good point to start solving a problem with you “messed up somehow”. I advice you using TortoiseSVN or any other subversion control system, so you can go back to previous versions of your script / scenes whatever and check, what you have changed…

are you tapping left/right? fixedUpdate doesn’t run every frame but at a fixed interval, if your input comes on a frame where fixedUpdate didn’t run it wont get picked up. Input really should be used in the Update function…

its all good but i have another problem, this line is supposed to stabilize the car so when im moving fast and i turn sharp it wont go all wonky on me (does bycicles, flips and even bicycles on the wrong side… looks very stupid and unplayable). this line did a little bit but didnt stabilize it well enouph. any suggestions… please make it simple :slight_smile:

rigidbody.centerOfMass.y = -0.09;