At any given moment, I’ve got three or four game ideas rattling around in my head. I never get past the prototyping phase, often because the idea doesn’t end up feeling novel or fun. But I had one idea with arcade-style vehicle physics that’s been more promising than the others.
I’m not going to give away my precious game idea for free here, but I will talk about the physics a little bit.
There’s a few different ways to simulate vehicle physics:
I built the raycasting solution, and the math that makes it work is pretty amazing (I did not invent this).
The basic idea is to apply forces to the body of the vehicle based on where the anchor point of each wheel would be on the body of the vehicle. This way, you can have any number of wheels, the vehicle responds to physics events in a way that is compatible with the physics engine (collisions, etc), and you can tune how the vehicle behaves and feels by changing the parameters of the forces applied, and to which wheels they are applied.
The setup is simple: you create a rigidbody for the body of the vehicle, and identify anchor points for the wheels. Each wheel has a forward vector and an upwards vector relative to the body of the vehicle that will determine how the forces are applied to the rigidbody. At each physics step, you calculate and apply forces for each wheel at its anchor point if that wheel is touching the ground:
Controlling the vehicle is simple: to accelerate, you apply torque to some or all of the wheels. To steer, you just rotate a wheel’s forward vector around its upwards vector.
With these simple forces, you can tune the vehicle to behave any way that you want:
This results in a vehicle that is very responsive to other physics forces as well. Things that fall on the vehicle will cause it to bounce on its suspension. You can lift the center of gravity of the vehicle to make it top-heavy, or put it on 3 wheels and it will topple over in sharp corners.
If you’re interested in more details on the math behind these forces, I recommend checking out this video.
The gameplay mechanics to this game are still mostly missing, but just driving these vehicles around is already a ton of fun. Maybe I’ll actually finish this one someday!