Improved Trucking Physics
June 7, 2012
Had another go at the WheelCollider, as I wasn’t convinced that completely custom built vehicle physics would save that much time, and I have made a couple of improvements. Most of all the Suspension is now correct, as I was doing it wrong most of the time:
- The best way to start is to set “Spring”, “Damper” and “Target Position” to zero.
- Set “Suspension Distance” to the distance you want the wheels to drop when the vehicle is in the air.
- Set “Spring” to something high (try 10240, depending on the weight and number of wheels of the vehicle) and start the game. Tweak the “Spring” value until the suspension is strong enough to keep the body of the vehicle from hitting the ground.
- Now set the “Damper” to roughly 1/20 of the “Spring” value and tweak it until the vehicle stops bouncing (depending on how much you like it to bounce)
- Note that everything you attach to the vehicle as well as the center of mass will affect the suspension behaviour and you will probably have to tweak it all over again
Here’s the new version with the improved settings.
Categorised in: Game development, HowTo, Uncategorized, Unity3D
Would you be willing to release a demo project for your truck/trailer combo?