Game Development Community

Platformer physics

by Andre Lind · in Torque Game Builder · 07/25/2006 (1:25 am) · 2 replies

Im building a platformer game and I need to know when the player leaves the ground so that I can turn gravity on
If I just enable it when the player jumps it works fine, but I want the to be able to shoot at the enemys and actually move them with the bullets... The bullets have a mass so the enemys move...

However, I need to know when the enemy (or player) leaves the ground
I thought of doing this with triggers along the ground, but should it be a nicer solution if the tiles did the callback?

#1
07/25/2006 (6:29 am)
Why don't you just enable gravity in the jump function. Then when the player collides with the ground turn it off. To disable gravity, use the OnCollison callback for whatever object is the ground.

May I ask why you don't want the player to be affected by gravity the entire time? It would be much simpler!
#2
08/01/2006 (8:55 pm)
This is a tricky situation because if you turn gravity off you will stop getting collision callbacks. One way is to do pickRect in an area towards the bottom of the player and see if any of the objects in that rect are "ground". This gets trickier if you're using tile layers because you have to check the collision boxes on individual tiles. It's best not to turn gravity off at all.