Jumping Problem

Non-platform specific questions.

Jumping Problem

Postby darokstar » Wed Jul 30, 2008 5:24 am

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.
I may be an idiot but that doesnt mean im dumb
darokstar
 
Posts: 13
Joined: Sat Jun 07, 2008 5:51 am
Score: 0 Give a positive score

Re: Jumping Problem

Postby feral » Wed Jul 30, 2008 6:48 am

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
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: Jumping Problem

Postby DST » Wed Jul 30, 2008 7:58 am

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:
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Jumping Problem

Postby darokstar » Mon Aug 04, 2008 2:17 am

Thanks :D
I may be an idiot but that doesnt mean im dumb
darokstar
 
Posts: 13
Joined: Sat Jun 07, 2008 5:51 am
Score: 0 Give a positive score

Re: Jumping Problem

Postby Fuzzy » Wed Aug 06, 2008 3:16 am

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.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron