I experimented a little with the Unity physics and wheel collider features to try to get a working truck + trailer configuration working for rough terrain.
As I had already done some truck and trailer physics for a farm simulator at work I wasn’t expecting this to be that tricky.
I uploaded my current state with still quite a number of problems and my research in forums has only resulted in finding many other developers not really happy with the build in car physics, saying you should do your own or use one off the Asset Store.
I’m not yet ready to give up on the built in system (but close).
Not working at the moment are:
- Suspension isn’t following the ground properly, especially with the twin-axles. Resulting in one axle having ground contact while the other is hanging in the air. I may have to reduce the real twin axles to a single virtual one, driving the visible twin axles.
- The truck tips over to easily. Lowering the center of gravity will fix this, but when tipping over the truck will then flip back to it’s wheels, looking pretty weird. I may have to animated the center of gravity so that it will rise if the truck is tipping over and lower it while it is going normally
- The trailer sometimes drags the truck pretty violently. It uses a configurable joint with restrictions but these sometimes pull very hard on the truck (or it may lift the truck into the air when braking hard).
- Sometimes the truck will not be able to gain speed. Very strange, I can only think of there being some large friction between truck and trailer leading to this behaviour.
- Grip and slip isn’t configured properly. Either the wheels simply spin or the wheels stick so violently to the ground that it tips over. It would be nice to get more information out of the wheel collider. This again speaks towards using a custom made system.