Game Development Community

Best Way to Implement Gravity?

by Brandon Haston · in Torque X 2D · 12/23/2008 (6:28 pm) · 1 replies

Right now I feel dirty because I'm simply adding a physics component with a permanent y velocity of +20.0f to every object I want to have "gravity" applied to.

With this implementation the objects just move down until they collide with something.

I was wondering though, is their a cleaner, more efficient way to implement a gravity system for a simple platformer? (I just want to be able to jump instead of flying upwards) I don't have the Platformer Starter Kit to look at for reference.

Thanks,
Brandon Haston

#1
12/23/2008 (6:41 pm)
Don't feel dirty - I think this is a great solution. Not everything needs to affected by gravity. If gravity was a constant in the game, then you need to set exclusions for the terrain (or tilemaps), platforms, clouds, backgrounds, etc. Adding a physics component to just those objects that need it makes the most sense and I'm pretty sure that's how the platformer kit works too.

John K.