Car Physics Package For Unity
The included Unity Package contains some scripts and sample prefabs to simulate realistic car physics in Unity. The simulation presented here does not make use of Unitys wheel colliders, but instead implements its ows wheel collider in script based on https://www.tradebit.comcast. The script then uses a Pacejka Magic Forumla-based tire model to calculate wheel forces to apply to the car, which gives better results.
Chances are, you dont need to know about the internal workings of the physics model. If you just want to play around with it, the best approach is to take the example prefabs, and start tweaking values, and see what happens. If you open the scripts, youll see that all parameters are explained in the comments. Try tweaking values a little at a time to get a feeling for it.
The included prefabs:
The package contains five car prefabs, and the skidmarks prefabs. To try it, just drag one of the cars and the skidmarks prefabs into the scene. You should now be able to drive around the scene with the car using the arrow keys. There are four realistic cars with very different characteristics included, to let you experiment with different physics setups, and one sports car with a more arcade-style setup (unrealiticly high grip).
All the car artwork used here are free models downloaded from the net for demonstration purposes, and not actually well suited for use in games.
The scripts are all based on realistic laws of physics, with the exception of the TractionHelper script, which is designed to make fishtailing cars more controllable with digital inputs. It acts somewhat similar as real-life ESP systems do.
The inlcuded scripts:
https://www.tradebit.com: One of these should be added to each car to calculate the aerodynamic friction.
https://www.tradebit.com: Optionally add up to one of these per axle to simulate anti-roll-bars for better handling.
https://www.tradebit.com: The script to handle car input. One of these is needed for each car. Edit this script, if you want to change how the car is controlled, or implement AI or network controlled cars. Also sets up some characteristics of the cars chassis, such as center of gravity and inertia.
https://www.tradebit.com: A cars engine and drivetrain. This is where you set up gear box and engine specs. One of these is needed per car.
https://www.tradebit.com: Global skidmarks manager. Add one Skidmarks prefab to your scene, which uses this class to render and manage skidmarks for all cars.
https://www.tradebit.com: Simple class to play engine and skid sounds. One of these should be added per car.
https://www.tradebit.com: Optionally add one instance of this per car, to make the car more stable.
https://www.tradebit.com: This simulates the tire traction and wheel suspension model, and acts as a replacement for Unitys built-in Wheel Collider.
https://www.tradebit.com: Add one or more of these if you want to simulate lift or downforce aerodynamics for your car.