racing game physics

Started by
5 comments, last by d1223m 18 years, 9 months ago
Hi, Im trying to make a Wipeout style racer ( http://homepage.eircom.net/~wipeout/site/wip3out/index.html ). Im wondering how I should go about physics and collision detection. Can I use ODE for something like this? I could probably use ode to make a body with wheels and then just hide the wheels but I dont like the sound of that too much :) Ideally I think each body would provide enough upwards force to keep itself hovering but im not sure if thats possible with ODE. Any hints? Cheers Dunk
eat veggie, program with soya: http://oomadness.tuxfamily.org/en/soya/index.html
Advertisement
you could use rays as "wheels" to get the distance to the ground at each corner of your vehicle. If the distance is below a certain distance you just apply a upward force to make the vehicle stay airborn
In my car simulation, I have a ray sticking out of each corner which basically acts as a spring. You could definately use such a method, but if the vehicle is meant to hover you'll want these 'springs' to be pretty squashy and long, so when you do a jump you don't suddenly bounce of the air when landing. This technique is demonstrated in my project, which you can see in action here. I'd also add another spring or two under the middle of the body. You might want some aerodynamic force too to push the vehicle down agaisnt the track - and for steering because I wouldn't recommend simulating a tyre gripping the ground for that at all!

I don't have time to explain this properly right know (at work) but if you PM or preferably email the address in my profile I'd be happy to explain better. I've not used ODE but any physics engine will allow you to do this - you're just adding forces to a body each update based on its position wrt the ground.
Thanks for the tips so far.

Iv managed to create a body that falls under gravity with ode. Then i am using ray picking to shoot one ray ( just one for the moment ) straight down. If the ray picks the floor im adding a force to the body like y_force / dist_to_floor.

While this works its very bouncy and i dont appear to be able to tune it. Am I going about this the right way? Ive thought of using a ODE slider to act like suspension but im not sure if thats over complicating things.

thanks
dunk
eat veggie, program with soya: http://oomadness.tuxfamily.org/en/soya/index.html
It's likely to stay bouncy as well. A good approach is to think in terms of a cushion of air under the vehicle - above a certain height it has no effect atall, below that height a lifting force is applied.

More importantly, below the critical height a new velocity-dependant resistance appears for vertical movement (this isn't a force which pushes you up - it only exists as drag when you are going down). That last bit allows you to use quite gentle forces without smacking into the ground whenever you do a jump.
maybe another solution? Build a second collision map from your track (on offset map), which is an offset of the normal collision map, and have a very rough collision shape for you ship's hull (say, a bunch of spheres), and collide those two, with 0 restitution, and a softer collision response.

That would roughly be equivalent of having you hull surrounded by large spheres (that are added to the ship's normal collision shape), and do very soft collisions between those spheres and the track collision (restitution = 0).

This will be equivalent to generating a strong force field at the spheres centre position, and making sure the track always stays at a distance from those points.

Everything is better with Metal.

Squirm, introducing the drag works great thanks, much less bouncy

Oliii, neat idea, might have to give that one a go. It could solve a few other probs too.

To make my craft move im using ode with ApplyRelForceAtRelPos to simulate the "engine" position ( some where at the back ) then to turn it im using the same function but with a different vector. Is that right? Im not sure how else to get it to move and turn.
eat veggie, program with soya: http://oomadness.tuxfamily.org/en/soya/index.html

This topic is closed to new replies.

Advertisement