Car goes a bit left when moving

Hello, i’m making a car project, i made 4 wheel colliders and made the 2 rear wheels move the war with motor torque, the problem is , i’m only using forward/backward movements, the car moves a bit to left / right when i change between forward and backward,

this is the car script, and below it the web player link if you want to give the game a try yourself

#pragma strict
var BackLeft : WheelCollider;
var BackRight : WheelCollider;
var VBR : Transform;
var VBL : Transform;
var VFR : Transform;
var VFL : Transform;

function Start () {

}
function Accelerate () {
BackLeft.motorTorque = Input.GetAxis("Vertical") * 100;
BackRight.motorTorque = Input.GetAxis("Vertical") * 100;
}
function Visual () {

VBR.Rotate(Input.GetAxis("Vertical") * 100 * Time.deltaTime, 0, 0);
VBL.Rotate(Input.GetAxis("Vertical") * 100 * Time.deltaTime, 0, 0);
VFR.Rotate(Input.GetAxis("Vertical") * 100 * Time.deltaTime, 0, 0);
VFL.Rotate(Input.GetAxis("Vertical") * 100 * Time.deltaTime, 0, 0);
}
function FixedUpdate () {
Accelerate();
Visual();
}

www.neoxads.com/sohaib/Screennie/Screennies.html

one wheel might be starting before the other

1 Answer

1

This is a pretty well known ‘bug’ or effect with the sideways slip value of the wheel collider. You can get rid of the issue by setting the sideways slip to a high value, however you then get a very ‘sticky’ wheel.

I’m going to guess you’re driving on a completely flat plane - when I’ve created a wheel collider object on rough terrain I’ve never had the issue.

how to add friction ?? can you please tell me....