Page 1 of 1

Roller coaster physics?

Posted: Wed Jan 06, 2010 12:21 am
by sinistral
Hi there,

I was wondering if anyone would be able to help me.. i've been trying to get my head around this for the past few days.. but with no luck.. :(

I want to create a roller coaster game.. so i will have a track.. and the cart must follow the track exactly and not come off it.. as it's a roller coaster the speed of the cart has to be quite fast.. but everything i've tried always end up with the cart leaving the track and flying off whenever a dip in the track is reached..

The cart is made up of a simple rectangular polygon.. with two circular wheels attached with pin joints to it.. the track is made up of segment shapes.. similar to the moon buggy demo..

Is there a way to 'stick' the cart onto the track?

So essentially... the wheels will follow the path of the track (which is curved), and always stay 'stuck' to it..

If anyone has any ideas or example code i'd be so grateful! :)

Re: Roller coaster physics?

Posted: Wed Jan 06, 2010 9:34 am
by viblo
Maybe you can do what real roller coasters do, add wheels on the other side of the track as well? That way it wont be possible for the cart to fly off.. I imagine you want to attach the other side wheels with spring joints to make it a bit smooth and reduce the risk of it getting stuck.

Re: Roller coaster physics?

Posted: Wed Jan 06, 2010 10:40 am
by slembcke
To be honest, if you want it to follow the track exactly, you are probably making things a lot more difficult by using a physics library. For a game like that you wouldn't even need collision detection. You would only need to track the acceleration of the car based on the slope of the track piece it's currently on. The physics for that would work out to be pretty easy.