Hello people,
I’m working on car physics for my racing game at the moment, and I thought I would get some feedback from you, especially those that are somewhat performance or physics savvy.
First of all, seeing as my game is just a one on one touge style racer, implementing proper solid body mechanics with 3D boxes would have no effect on performance at all, as it’s not like I’m doing Burnout style pile ups ets.
However, in keeping with my general philosophy of keeping things as simple and fast as possible, I at least want to develop super quick 3D car physics, even if I decide to implement a slower, more complex solution.
So for starters the fastest means of representing the car is going to be a 3D rectangle. Unless your car game incorporates 360 rolls and cars landing on top of each other etc, proper 3D box physics is unnecessary.
A rectangle is only 4 particles and 5 constraints.
And the fastest means of achieving a car to car collision that looks convincing enough is actually going to be having the cars represented as 2 spheres for car collisions.
This can be done by averaging the positions of the particles on the car to position the spheres to occupy the front and back end, rather than using more constraints to physically connect them.
Then when a car is in close enough proximity, check the spheres for collisions. If the rear sphere collides, apply force to the rear particles etc.
It remains to be seen how well this works, but on paper it should work OK.
Now car to environment collisions are trickier. More complex by nature, and also important to get running fast because as opposed to car collisions which are occasional, each car is pretty much constantly colliding with the environment.
The fastest method I can think of is basically just rectangle to triangle collisions. In each node check the 4 points against all the triangle faces in the current node, resolve collisions as necessary.
However you also need to check all 4 edges of the rectangle against each edge of each triangle, imaging driving your car into the edge of a wall etc, edge to edge collisions are going to be pretty common.
Checking triangle points to the face of the rectangle is unnecessary, I can’t really think of a scenario where this collision would occur without any of the other collisions occuring.
If you can think of a faster, equally solid method, feel free to suggest it
Cheers,
RumbleSushi