# Is there a good existing starting point for realistic 2d racing car physics?

I'm trying to get a realistic behaving racing car into my 2d top-down game.

Making a very simple car that drives around is straight forward but I want a reasonably sophisticated model that models Newtons laws and the forces on the car well and results in something great.

I searched the web for a good tutorial on how to do this but there doesn't seem to be much example code out there.

I followed this tutorial http://www.gamedev.net/topic/470497-2d-car-physics-tutorial/ which was very good and seems like a good starting point but if you have a play with the included demo you can see it still has a fair way to go before its a convincing racing car.

I hear that some 3d game engines like Unity come with a good starting vehicle model out of the box. Is there something like that out there for 2D?

Just want to make sure I am not missing some great existing 2d starting point I don't know about before I spend a LOT of time reading and figuring out all the correct forces etc needed to build my own from scratch.

This article seems to describe all the things you need: http://www.asawicki.info/Mirror/Car%20Physics%20for%20Games/Car%20Physics%20for%20Games.html but the source code links are broken unfortunately.

-

This started as a comment, but got too long. :)

If by "realistic", you mean including weight transfer back/front or left/right when accelerating/braking/turning, you need a 3d-model for the car it self (since there will be forces & rotation around three axis), even if it runs on a flat 2d surface. Thus using a 3d-model might be the only way to get what you need, and you could borrow/steal some existing code (but simplify the wheel to road surface distance computation).

If you don't need that, some basic newton + a static/dynamic friction model for each wheel based on it's slip angle (i.e. the wheel's angle in relation to it's direction of travel) should suffice. There's lots of info to be found in race car driving books about that. (Max side force is usually at 3-6 degrees slip, but this varies depending on slicks vs. threaded and the surface (tarmac, cement, gravel, etc.))

-

There are a few GPL driving physics engines around, which might work for you. I can't find the one I was looking for, but http://vdrift.net/ seems like it might be a good start. I think I would use a 3d physics engine even for a 2d game - you're presumably going to want jumps and so on even if they're only shown by scaling the car.

-

Box2D is a quite popular 2D physics engine. It doesn't have a racing model built-in, but it seems to be a solid general-purpose physics engine, so you won't have to bother with the details of basic rigid-body mechanics, collision, friction or constraints.

-
Hi Nathan, yeah sounds like its a good idea to use box2d or farseer etc to help with those things. I think the tricky part I'm missing is knowing how to apply all the necessary forces to make it behave like a great racing car. The formulas are all out there but surprised I couldn't find something that is already most the way there given how often this problem has been solved. – TerryB Oct 26 '11 at 2:07