Hi, I am quite new to making cars and I am currently making a free roam game. The problem is that when i start driving, even the slightest speed my car starts twitching from side to side… I will try give as much details as possible, apart from that please help
^This is just a screen shot of my current scene and how my Buggy/Car is setup + how the wheel colliders are set.^
@ImThatZombie Try setting the center of mass to something slightly around -1 on y axis.
Consider using antiRoll script, here`s mine, copied from tutorial and bit tweaked to work with my code
public class AntiRollBar : MonoBehaviour
{
public WheelCollider WheelL;
public WheelCollider WheelR;
private Rigidbody carRigidBody;
public float AntiRoll = 5000.0f;
// Start is called before the first frame update
void Start()
{
carRigidBody = GetComponent <Rigidbody>();
}
// Update is called once per frame
void FixedUpdate()
{
WheelHit hit = new WheelHit();
float travelL = 1.0f;
float travelR = 1.0f;
bool groundedL = WheelL.GetGroundHit(out hit);
if (groundedL)
{
travelL = (-WheelL.transform.InverseTransformPoint(hit.point).y
- WheelL.radius) / WheelL.suspensionDistance;
}
bool groundedR = WheelR.GetGroundHit(out hit);
if (groundedR)
{
travelR = (-WheelR.transform.InverseTransformPoint(hit.point).y
- WheelR.radius) / WheelR.suspensionDistance;
}
var antiRollForce = (travelL - travelR) * AntiRoll;
if (groundedL)
carRigidBody.AddForceAtPosition(WheelL.transform.up * -antiRollForce,
WheelL.transform.position);
if (groundedR)
carRigidBody.AddForceAtPosition(WheelR.transform.up * antiRollForce,
WheelR.transform.position);
}
}