Car Physics Woes

Posts: 156
Joined: 2002.10
Post: #1
I am looking to create a game world in which the player can drive cars, trucks etc. around. I'd like the system to support true 3D in the sense that the ground may have bumps, hills, and the vehicles could 'get air', or perhaps fly off a cliff - stuff like that. I'd also like to have collision detection implemented for a number of primitives if possible, i.e. the cars can crash into stuff like trees, walls. The physics should be 'realistic' but playability is the key idea, rather than total realism.

I have had a play around with both ODE and Newton, which seem to be the most popular (and free) physics engines around, but building a car which performs well seems to be pretty difficult. Does anyone know of any libraries (or wrappers around ODE / Newton) that will allow me to create and drive cars around? Or does anyone have any source code they would be willing to share? I have googled around a bit, but most stuff appears to be win32 based Sad I don't want to be re-inventing the wheel ( Rasp ) so if anyone has tried this or seen anything that would help, that would be great!


- Iain
Quote this message in a reply
Posts: 613
Joined: 2004.09
Post: #2
Physics code should be "decently" portable from a Win32 machine and not that you an incredible amount of time. Im sure there has been some open source stuff with car physics in it, I recall some sort of school bus game here if you can dig up the info on that maybe the programmer could share it with you.

If you got some cash to blow the game programming gems set of books has a wealth of infomation on it.

Kyle Richter
Twitter: @kylerichter
Quote this message in a reply
Post: #3
I thought ODE had some sort of car example you could just modify to suit your needs. Or a car creator. Or something.

I honestly don't remember but it shouldn't be terribly difficult to do if you've tried simpler things in ODE before. And check out previous threads here (I remember at least one which went over this in some detail).
Quote this message in a reply
Posts: 78
Joined: 2002.06
Post: #4
Both ODE and Newton have *basic* car examples. However car physics is hard. Have a look at Racer and at BitRacer (my game using ODE) . Both have their source code available. I'm writing a similar game ( to what you are after and can probably give you more specific tips if you are interested.
Quote this message in a reply
Posts: 1,199
Joined: 2004.10
Post: #5
You have to take into account the kind of dynamics you're interested in. Are you making a racing game, or an off-road game, or a military sim?

Also, I can't speak for newton, but in ODE you can't use flat capped cylinders against a trimesh ground -- so your wheels will have to be spheres. In fact, ODE pretty much sucks compared to Newton. Newton's faster, allows you to have arbitrary mesh volumes attached to kinetic bodies ( in ODE, you can use arbitrary meshes for collision, but they can't move ).

If I hadn't already spent 6 months and written something like 20 or 30 kloc of my game around ODE's physics, I'd switch over to Newton in a heartbeat. Cry

Anyway, regarding car physics, don't be afraid to simulate a suspension. After all, cars have suspensions for good reason -- stability and maneuverability. In my game I have a very simple "single wishbone" style suspension and four-wheel drive, with a large, squat wheelbase. My vehicle is very stable, and yet still I have good cliff-jumping and bounciness.

Also, you should consider how you handle flipping situations. Do you simply *prevent* flipping, like in Simpsons Hit & Run? Or do you let the car flip, but then just wait a few seconds and return it to the track? Or do you allow the game to continue but provide some sort of manual unflipping mechanism ( this is what I do ).

Regarding free examples of car physics, I imagine google will be your friend there. But for what it's worth, nothing's the equal of just figuring it out yourself. It's not very hard, and it can be a lot of fun to develop your own system.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Bullet Physics Library / COLLADA physics viewer erwincoumans 14 19,275 Aug 12, 2006 12:59 AM
Last Post: Fenris