Which physics engine models driving well?

Community Forums/General Help/Which physics engine models driving well?

TaskMaster(Posted 2010) [#1]
I see a lot of physics engines being advertised and/or used around here. Is any one of them good for doing a 2D driving game? I want it to seem fairly realistic, with spin outs, drifting, etc.

If there is something good available already, that would be great. I would rather use something like that, rather than start coding my own.

Decent driving physics really are quite complicated, with measuring force on each tire, shifting weight, etc. If i have to do my own, I will probably go this route, but if there is a fairly decent engine that will seem real, then I would like to try it first.


Vorderman(Posted 2010) [#2]
Any of the full physics engines (Tokamak, ODE, PhysX) can be used in 2D just as well as 3D, just ignore the vertical aspect when moving from the physics objects to your 2D sprites.

The only good vehicle simulation I've managed to get working is with Tokamak, despite ODE having excellently bouncy carwheel joints.

I spent a few years making and working with an ODE lib when Blitz3D was first released but never managed to get the vehicle to behave itself when sliding or when moving fast. Same with PhysX, they all seem to suffer from the same snap-spinning behavior and get very twitchy at higher speeds.

For some reason Tokamak's friction / contact method enables the wheels to slide in a much nicer and more progressive way, so my Tokamak cars in Stunt Race can perform full opposite-lock powerslides of almost any duration, they can power-understeer and oversteer and also lift-off oversteer if you come off the power during hard cornering.

I've not yet seen any ODE or PhysX vehicle demo that can do this.

If you want slower-moving vehicles that don't slide around and with bouncy suspension, use ODE (or PhysX). If you want fast vehicles that can drift etc.. use Tokamak.

I also have my own custom 2D vehicle physics engine but it's taken about 10 years to develop so it's not available to anyone else, sorry :)
Short video of it here: http://webspace.mypostoffice.co.uk/~james.kett/B3D_drift.flv


TaskMaster(Posted 2010) [#3]
That video looks pretty dang good.

I'll look at Tokamak. Thanks for the info.

I figured I might have to model my own. Which is OK, I think it will be kinda fun to develop, but I also know it will take some time.


Vorderman(Posted 2010) [#4]
Yeah, it took me ages. That video clip isn't using Tokamak just a very upgraded version of Marco Monster's 2d physics code :

http://regedit.gamedev.pl/Mirror/Car%20Physics%20for%20Games/Car%20Physics%20for%20Games.html

http://hamboeck.blogspot.com/2008/03/marco-monsters-car-physics-demo-in-xna.html


Vorderman(Posted 2010) [#5]
Check out this old Tokamak rally demo that's recently been found again:

http://www.hi-toro.com/blitz/misc/tokamakrally.zip

it works pretty well and would form a nice basis for any driving game.


TaskMaster(Posted 2010) [#6]
I have seen both of those links you posted. The first one is still open in a tab, I have been studying it, along with the Physics for Game Programmers book.


EOF(Posted 2010) [#7]
I played around with Monstrous Softwares 2D car simulation. I added the ability to reverse which is something the original never add. The sim works quite well but I think sometimes the car can slide infinitely sideways if you turn, brake, then self-correct the wheels:




TaskMaster(Posted 2010) [#8]
Thanks.

When I get a chance, I will take a look at this.

I appreciate any hints/help I an get.


Damien Sturdy(Posted 2010) [#9]
See, I've always disagreed with Vorderman about ODE, despite me using his wrapper on the very game I'm about to link,

http://damiensturdy.servegame.org/ ,check out the B3D racer, link to download here:
http://damiensturdy.servegame.org/downloads/RACER_20_01_10.rar

It took a lot of work and even a fair bit of manual calculation, but if you play as the Mazdo car in this you'll see it's actually quite possible with ODE and I find ODE really easy to set up. The above actually uses both Vorderman's ODE wrapper AND JV-ODE. for some reason porting to JV-ODE never worked, so I wrapped JV-ODE code into Vorderman's functions, and whump, away it went first time lol.


That said, I've also had great fun with Tokamak, although I've never quite got a good suspension out of it.


BlitzSupport(Posted 2010) [#10]
Got a 404 on that link, Cygnus. Same going from the site itself.


Vorderman(Posted 2010) [#11]
Good to see that my ODE wrapper still rocks!!!

I prefer Tokamak though :)


Damien Sturdy(Posted 2010) [#12]
Darnit! I changed my server layout. Fixed!!! :-)

Also, since when are we allowed to have commas in links? X-D this forum software thought my proceeding comma was part of the URL.

Vorderman - YOU are the reason I never gave up coding all those years ago, and last November I found the racer and said "Hmmph, such a shame, the wrapper is small and efficient, yet it suffers some old ODE bugs." - so I removed your DLL calls and replaced them with calls to JVODE functions. I'd already heavily modified your code so this was the easiest way forward.

Anyway, have a play. You're right that you can't do infinite powerslides, but the Mazdo is pretty close lol. It all depends on what you need really, Tokamak didn't give me an impressive view that's all, but Toka is WAY faster.


Vorderman(Posted 2010) [#13]
YOU are the reason I never gave up coding all those years ago


You say that like it's a curse!!


Damien Sturdy(Posted 2010) [#14]
Hahaha, Not a curse, I've had a darn great time!