- Home /
Car flips, wheel colliders
I have a car drive script, and when i try to turn the car (left or right) the car starts to flip i have wheelcolliders to each wheel (frontl, frontr, backr, backl) every wheelcolliders is a emptygameobject and all of those wheelcolliders inside other gameobject, then i have another emptygameobject called "Wheels" inside this emptygameobject
there are 4 more emptygameobjects and inside each of these 4 there is a wheel (model), this the code (the code is attached to the car):
var wheelFL : WheelCollider;
var wheelFR : WheelCollider;
var wheelBR : WheelCollider;
var wheelBL : WheelCollider;
var speed : float;
function Start(){
rigidbody.centerOfMass.y = 0;
}
function FixedUpdate(){
wheelBL.motorTorque = speed * Input.GetAxis("Vertical");
wheelBR.motorTorque = speed * Input.GetAxis("Vertical");
wheelBL.brakeTorque = 0;
wheelBR.brakeTorque = 0;
wheelFL.steerAngle = Input.GetAxis("Horizontal") * 10;
wheelFR.steerAngle = Input.GetAxis("Horizontal") * 10;
if(Input.GetKey(KeyCode.Space)){
wheelBL.brakeTorque = 20;
wheelBR.brakeTorque = 20;
}
}
rigidbody.centerOf$$anonymous$$ass.y = -1;? How much lower?, i tried -0.85 but that didn't worked..
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Unity 3.4.0 Running really slow 1 Answer
Up and down camera with mouse wheel 0 Answers
Car flips when it turns 1 Answer
Mecanim Tutorial Problem 2 Answers