- Home /
Car Tutorial Alt Physics Torque Steering
Hey,
I've been playing around with the Alt Physics model in the Unity Car tutorial and I really like it so far, but I'm having a problem with front wheel drive cars.
When the car is set to rear wheel drive, I don't get any random veering, which is good, but when I set the two powered wheels to the front, I get these random torque differences between them while driving on flat surfaces, which causes the vehicle to veer in one direction or the other. I've looked it up and it's called Torque Steering (http://en.wikipedia.org/wiki/Torque_steering), and there's a solution implemented already. It seems to follow the formula for a LSD (http://en.wikipedia.org/wiki/Limited-slip_differential). However, I think it's programmed strangely, or at least impossible to calibrate. Here is the official solution:
float drivetrainFraction = 1.0f/poweredWheels.Length;
float averageAngularVelo = 0;
foreach(Wheel w in poweredWheels)
averageAngularVelo += w.angularVelocity * drivetrainFraction;
// Apply torque to wheels
foreach(Wheel w in poweredWheels)
{
float lockingTorque = (averageAngularVelo - w.angularVelocity) * differentialLockCoefficient;
w.drivetrainInertia = inertia * drivetrainFraction;
w.driveFrictionTorque = engineFrictionTorque * Mathf.Abs(ratio) * drivetrainFraction;
w.driveTorque = engineTorque * ratio * drivetrainFraction + lockingTorque;
slipRatio += w.slipRatio * drivetrainFraction;
}
// update engine angular velo
engineAngularVelo = averageAngularVelo * ratio;
I've gotten as far as recognizing that we should multiply in the square of the radius of the wheel to convert angular velocity to torque:
float lockingTorque = (averageAngularVelo - w.angularVelocity) * w.radius * w.radius * differentialLockCoefficient;
...but other than that, I'm stumped, and don't really know how to calculate the correct coefficient. There has to be a better solution out there to correct for this in FWD cars. Does anybody have it?
For any cars at all. I would just use Edy's vehicle physics. Why waste months developing something that already totally exists you know?
I don't really have the money to spend at the moment.
Besides, for some of us, getting there is half the fun ;)
"Besides, for some of us, getting there is half the fun ;)"
I appreciate you're just joking, but it's not really in that category.
I'd look for and use one of the free car rigs around.