Saturday, January 25, 2014

Steering, skidding and avoiding spin-out

Richard and I talked about the possibility of having the handling of the dots feel more 'car' like, and wondered whether that would make things more fun. More skidding and steering.

I've been fiddling with Unity's wheel colliders to see how feasible this would be. In case you didn't come across these before, they're a special kind of physics-enabled object that have independent friction curves for forward (rolling) and lateral (skidding) movement. Wheel colliders also have steeringAngle and motorTorque properties to quickly get them behaving as you'd want when building some kind of vehicle.

I've based my 'dot' controller here on a stripped-down version of the futuristic sports car controller in Unity's new Sample Assets package.

The first problem I noticed is that it was very easy to get into an uncontrolled spin, which wasn't much fun. There ought to be plenty of skidding round corners, but very little spinning.

While googling spin-out I found this wikipedia article

in a car with a short wheelbase, the short lever arm from the CM to the rear wheel will result in a greater lateral force on the rear tire which means greater acceleration and less time for the driver to adjust and prevent a spin out or worse.

Sure enough lengthening the wheelbase helped a great deal.