Page 1 of 1

Jumping Problem

PostPosted: Wed Jul 30, 2008 5:24 am
by darokstar
Hello peoples :D When I make a platform game my player can walk off the tiles and then jump again I know why it does this I just need to know if there is a way to fix it.

Re: Jumping Problem

PostPosted: Wed Jul 30, 2008 6:48 am
by feral
this sounds like a common problem called "flying" or multiple jumping

check out this thread
viewtopic.php?f=2&t=4774&p=30212&hilit=canjump#p30212

( there are many more - search for the term - canjump ,( which is just an ordinary variable name that most of us use when solving this problem)

let me know if that doesn't help

Re: Jumping Problem

PostPosted: Wed Jul 30, 2008 7:58 am
by DST
He's talking about walking off the edge, but canjump remaining 1 (because jump button wasn't pressed).

Now this is the kind of thing that collision free is supposed to be used on, but it never seems to work on the y axis.

A more reliable approach is to do this:

Player1>Collision>TopSide of Ground>
CreateTimer("Event Actor", "timername", 50);

Then on
Player1>CollisionFinish>Ground>
DestroyTimer("timername");

And on
Player1>Timer>
canjump=0;

You may have to adjust the timerlength to suit your game. I have mine at 50 and it works quite well. (60fps game)

NOW
Some of you may be thinking, shouldn't that be the other way around? Shouldn't collision finish Create the timer and Collision destroy it?
Well this is where it gets interesting. I have it the other way around on my stairs. Works fine. But on my ground it doesn't. What i posted here is the way it works for my ground and platforms.

If it doesn't work for you this way then switch it. :mrgreen:

Re: Jumping Problem

PostPosted: Mon Aug 04, 2008 2:17 am
by darokstar
Thanks :D

Re: Jumping Problem

PostPosted: Wed Aug 06, 2008 3:16 am
by Fuzzy
If I understand the problem right, canjump is on during a fall, so the player can jump when he shouldnt.

Two ways I can see to avert this.

First would be to check the yvelocity against a threshold. If its more than the initial acceleration from falling, then turn off canjump. This would let a player jump for a split second after falling.. sort of a last ditch attempt.

The other way would be to have a second variable that tracks if the player is currently in the air. Thats what DST's solution does with a timer. Its saying "I havent touched ground in 50 milliseconds, so dont let me jump." You might set it as soon as the jump button is pressed, but depending on the game, a jump may not succeed. Use DST timer instead, or my first solution.