Roller coaster physics?

Official forum for the Chipmunk2D Physics Library.
Post Reply
sinistral
Posts: 1
Joined: Wed Jan 06, 2010 12:14 am
Contact:

Roller coaster physics?

Post 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! :)
viblo
Posts: 206
Joined: Tue Aug 21, 2007 3:12 pm
Contact:

Re: Roller coaster physics?

Post 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.
http://www.pymunk.org - A python library built on top of Chipmunk to let you easily get cool 2d physics in your python game/app
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Roller coaster physics?

Post 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.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests