Which physics engine for driving/racing games?Blitz3D Forums/Blitz3D Userlibs/Which physics engine for driving/racing games?
| Which physics engine is best for driving/racing games? |
| Hi jeffmorris,|
If you searched for old thread about driving, tokamak is said to be the best for this. However, it is no longer updated, I would recommend JV-ODE as it comes with simple car coding.
| JV-ODE is the currently most supported, robust and intuiative physics implementation for B3D.|
tokamak (and anything based on it like easytok) has some underlying bugs relating to deleted objects that can cause it to crash so I'd avoid that.
Theres the PhysX wrapper source floating around which is quite well featured but not supported and a lot more work than JV-ODE to implement.
| http://blitzbasic.com/Community/posts.php?topic=90281 |
| I'll 2nd the vote for JV-ODE, from Artics to small cars - its great for animating vehicles. |
| Tokamak is far better for vehicles than ODE, despite ODE's carwheel joint - Tokamak's friction copes better with sliding bodies and it seems to handle the inertia better avoiding the snap-spinning that happens with ODE.|
I've used both ODE and Tokamak for years (ODE since just after B3D was released when I wrote the first B3D ODE wrapper) and have never achieved a decent vehicle sim in ODE that holds up at speed, and I've not seen anyone else do it either.
In contrast using Tokamak I've got a solid vehicle physics system in SRX that allows full drifting, power-under and oversteer and lift-off oversteer, and the actual physics section of this is not that complex - basically it just varies the friction and linear & angular damping on all 4 wheels seperately depending upon speed, throttle, steering input etc... to simulate the grip level the tyre would provide.
I've yet to see an ODE sim that can do these things, and that includes Racer (which I believe even incorporates an advanced tyre model) - they all suffer from either having limited speed to avoid problems, the infamous ODE wheel wobble at high speed (where the forces overcome the fixed joints and the rear wheels start to steer themselves), and instant snap-spinning when the wheels start to slide.
If your sim is slow-moving and requires nice bouncy wheels and no sliding, ODE is fine. If you want to drive fast and allow skidding, Tokamak is far better.
I've not used PhysX beyond running the demos so I can't really comment, but the PhysX car demo feels very similar to ODE, with the same spinning problems.
Last edited 2010
| Also, unless you need the car to move in full 3D, I'd suggest looking up Marco Monster's 2D car physics code - it provides a really good and reasonably simple physics engine that works on a 2d plane, and it can be modified to allow some pretty amazing drifting and sliding.|
Last edited 2010
I've used both ODE and Tokamak for years (ODE since just after B3D was released when I wrote the first B3D ODE wrapper) and have never achieved a decent vehicle sim in ODE that holds up at speed, and I've not seen anyone else do it either.Oh, I stand corrected.
In contrast using Tokamak I've got a solid vehicle physics system in SRX that allows full drifting, power-under and oversteer and lift-off oversteer, and the actual physics section of this is not that complex - basically it just varies the friction and linear & angular damping on all 4 wheels seperately depending upon speed, throttle, steering input etc... to simulate the grip level the tyre would provide.I've seen your SRX and it looks mightily impressive - all along I though it was JV-ODE.
What I will say for JV-ODE is that I have had a great amount of gratification from coding with that physics engine - I have not tried Tokamak so I bow to your greater knowledge.
Within JV-ODE I managed to create an articulated cab with a trailer with a tailgate akin to the one on Knight Rider, to the extent that you could change control between car & truck & drive the car into the back of the trucks trailer. I confess the graphics never quite made it - however as a proof of concept it worked very well - in fact it exceeded my expectations as to how much an indie coder could achive.
In your opinion, can tokamak also achieve this? I'm not knocking Tokamak without having tried it - I'm just interested in your slant on it.
Last edited 2010
| Tokamak is a bit different to ODE in that it has no specialized joints for vehicles - ODE has the built-in carwheel joint with suspension, which allows some excellent bouncy wheels and working suspension. For slower moving vehicles it works really well, probably better than Tokamak at least in terms of how realistically it rides over bumps.|
The first problem comes when you try to make the vehicle move fast - I followed the ODE mailing list for ages and endless people had problems where the carwheel joint (which can be locked so it can't steer - used for the rear wheels) would twist out of alignment when the forces built up. I never saw a solution to this unfortunately. Even using a fixed axle resulted in the same problem, so cars would rear-wheel steer when cornering fast or sliding. Although you have to fake the equivalent carwheel type of joint in Tokamak it does not seem to suffer from this twisting of the joints.
The second problem relates to the friction between the wheels and the ground - you seem to reach a point in ODE where the wheel suddenly slides, and it causes the car to spin around uncontrollably or flick from left to right with apparently little regard for the momentum of the vehicle. For some reason Tokamak copes much better with this and the wheel objects slide in a nicer and more progressive way, although I've no idea why this would be.
The other thing is I've never managed to "explode" the Tokamak simulation, despite doing some really nasty things to it. In contrast it seemed very easy to break ODE's simulation. Tokamak has a problem where bodies can be forced through the static collision mesh, and this occasionally happens in SRX if you hit a vertical wall head on at really high speed - so far I've not found a technical solution, so I give the player a reset option or break the wheels right off the car, both of which are a bit of a bodge but work OK.
In terms of the truck trailer and car, yes Tokamak can easily do that sort of thing, but you'd have to create your own version of the carwheel joint.
Last edited 2010
| I've been messing around with a sort of Super Off Road / Ironman Stewart type game (much more arcadey than SRX and played from a 3rd person elevated view as in the original game) to see how bouncy I can make my simplifed little Tokamak trucks, so I've added a second truck and hooked it up to the first to act as a trailer, just to see what happens.|
Now ideally the trailer would have just 2 wheels at the rear and not weigh as much as the truck itself, but you get the idea...it took 7 extra lines of code to link up the trailer, so very simple.
Please forgive the crap video quality, first time I've ever uploaded anything to YouTube - hopefully you can just about make out what's going on!!
Last edited 2010
| hi, as i see you have some more experience in this area.|
i played some with cars and jv-ode:
please take a look and tell me your opinion. The most important part is the "UpdateCars" function in which the friction and slip forces are used (well, i try to manage them...) Mu, Mu2, Slip1, Slip2 and FDir1
thank's in advance
| This is fun - removed the front wheels from the trailer, doubled the truck power and added a towbar...|
Wonder how it would cope with 16 AI cars all with trailers....
| @Voerderman, looks cool, reminiscent of skid marks albeit a lot more evolved. |