Odd Rotation using CarPhysics

In our game, every time a car begins to accelerate, or brake quickly, it rotates a direction for no reason I can figure.

And usually which ever way it rotated towards during acceleration, it will rotate the opposite direction when braking. The trees of rotation are usually from 0-3.

The WheelColliders are positioned Symmetrically, the center of mass is centered as well, (granted lower). I’m thinking its a bug, Here is the script im using:

using UnityEngine;
using System.Collections;

public class LiteCarControl : MonoBehaviour {

 public WheelCollider[] wheelColliders = new WheelCollider[4];
 
 public Transform centerOfMass;
 
 public float steerMax = 45;
 public float motorMax = 10;
 public float brakeMax = 100;
 
 private DrivingInstructions inputs = new DrivingInstructions(0,0,0);
 
 private void Awake(){
 this.rigidbody.centerOfMass = centerOfMass.localPosition; 
 }
 
 private void FixedUpdate(){
 inputs.motorInput = InputManager.Instance.Accel; //gives me a range of 0-1
 
 wheelColliders[0].motorTorque = motorMax * inputs.motorInput;
 wheelColliders[1].motorTorque = motorMax * inputs.motorInput;
 wheelColliders[3].motorTorque = motorMax * inputs.motorInput;
 wheelColliders[2].motorTorque = motorMax * inputs.motorInput;
 
 //Disabled below for test
// wheelColliders[0].steerAngle = steerMax*inputs.steerInput;
// wheelColliders[1].steerAngle = steerMax*inputs.steerInput;
 
 }
 
}

try this

using UnityEngine;
using System.Collections;

public class LiteCarControl : MonoBehaviour {

 public WheelCollider[] wheelColliders = new WheelCollider[4];

 public Transform centerOfMass;

 public float steerMax = 45;
 public float motorMax = 10;
 public float brakeMax = 100;

 private DrivingInstructions inputs = new DrivingInstructions(0,0,0);

 private void Awake(){
//heres what i changed
 this.rigidbody.centerOfMass = Vector3(0,0,0); 
 }

 private void FixedUpdate(){
 inputs.motorInput = InputManager.Instance.Accel; //gives me a range of 0-1

 wheelColliders[0].motorTorque = motorMax * inputs.motorInput;
 wheelColliders[1].motorTorque = motorMax * inputs.motorInput;
 wheelColliders[3].motorTorque = motorMax * inputs.motorInput;
 wheelColliders[2].motorTorque = motorMax * inputs.motorInput;

 //Disabled below for test
// wheelColliders[0].steerAngle = steerMax*inputs.steerInput;
// wheelColliders[1].steerAngle = steerMax*inputs.steerInput;

 }

}

if that doesn’t fix it see what your transform calls 0,0,0 it may be that the center of your object is 5,0,5

the change had No effect, and the object is perfectly balanced, I even created a basic one with just a box and wheel colliders, and the issue still shows. again, everything mathematically is balanced…

So ive put together a Unity Package for download here:
theLink

it is set to expire in 60 days, please try and and let me know if you run into the same thing