Page 1 of 1

Air jumping

PostPosted: Sun Jun 04, 2006 6:49 pm
by SuperLarryo
I've fixed the jumping multiple times with the variable onGround. onGround is always 1 (true) when my character is touching the ground, or the top of an object or platform. My problem is that when I hit spacebar, onGround becomes 0 and my character jumps, but if I just fall off a platform without hitting spacebar, then I hit spacebar afterwards, I jump on thin air. Is there a way to fix that? I'm not sure how.

PostPosted: Mon Jun 05, 2006 3:41 am
by makslane
Put onGround = 1 when the player colllides with platform and onGround = 0 in a collision finish with platform.

PostPosted: Tue Jun 06, 2006 9:25 pm
by pavel329
yeah i always have that problem.its like my guy can fly.lol.i just never felt like asking.lol.

PostPosted: Wed Jun 07, 2006 2:11 am
by DilloDude
It depends how you do the collision, with physical response, it makes it stop colliding, and the increasing yvelocity makes it collide again. You can experiment by setting a textNumber to onground, and watch it flicking between 0 and 1. My method is to use a timer that is destroyed on collision with ground, and then created again. On the timer it knows you are off the ground. I have experimented with a few different times: with 50 ms, the timer runs out before the next collision, causeing the same flicking between 1 and 0. With 200 ms, it goes off a bit too late, and you can get a second jump in just after leaving the ground. With 100 ms, if you press really fast, you can jump again, but it is so close not to make much difference, and you can only tell if you make it play a sound.
You might also like to check out my post
http://game-editor.com/forum/viewtopic.php?t=1890
to find out how to alter the hight relative to the time you hold the jump key.

PostPosted: Wed Jun 07, 2006 11:37 pm
by SuperLarryo
It worked. The collision finish does the trick. Thanks guys.