Jump to content
  • Advertisement
Sign in to follow this  

Roller Coaster physics

This topic is 4248 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! I would like to know how to simulate roller coaster physics in a roller coaster game... How can the train be attached to its rails everytime? Do you have any simple way to do this? Thanks by advance!

Share this post

Link to post
Share on other sites
Represent your track as something like a spline or a bezier curve, etc...

Make your coaster cars solid bodies so that they can have forces applied to them.

Apply the necessary force from gravity. If the car deviates from the track, the track will also apply forces to keep it on the path. I'm sure there are fancy ways to handle these constraints so that it remains numerically stable and such. However you could probably start with "car is below path...apply force up!" and make it work alright.

Integrate the whole business using your choice of method (depending on the complexity of your motions and the timestep), and it should behave somewhat realistically.

Share this post

Link to post
Share on other sites
It might be fruitful to constrain the motion of the coaster to the track, and figure out velocity through kinetic (T) and potential (V) energies.

At the top of a hill, before the cart is released, you have a kinetic energy:
T = ½mv2 = 0
and potential energy:
V = mgh
so that the total energy is:
E = T + V = mgh = constant

At any given height on the track, your velocity can be found like this:
T = E-V
v = sqrt(2(E-V)/m)

Neglecting of course, air resistance, which will wear down on the total energy E over time. When the cart gets near the top of the next hill, it should be grabbed by the track, slowed, and brought into position at the top of the next hill, starting the process over again.

For air resistance:
ΔE = FDs = C1<v2>Δs

Variable definition:
T: kinetic energy
V: potential energy
E: total energy
m: mass of coaster
g: local gravitational acceleration (-9.8m/s or -32ft/s)
h: height of the cart
v: velocity along the track
s: path distance along the track
<v2>: average of the v2 during that time interval
FD: drag force
C1: a constant effecting the drag force. I recommend starting with half of the cart's forward area and tweaking until content.

Some people may argue that it's best to use v instead of v2, but I chose the square term because the cart will create turbulence.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!