Page 1 of 1

Jump after falling off platform

PostPosted: Sun Feb 19, 2012 4:03 pm
by badchad024
I was having problems with double jumping but figured out how to use the canjump variable and fixed it. Now im having a problem with anytime i run off the edge of a platform i can still jump. I have made it to where when collision with platform canjump=1; and when i press space canjump=0; maybe im doing something wrong please help!

Re: Jump after falling off platform

PostPosted: Sun Feb 19, 2012 9:30 pm
by skydereign
Really what you want to do is to set your jump variable to 0 if you fall off the edge. The problem becomes trying to figure out when you are falling. But since you want to have double jump it isn't as easy as just seeing if the actor is falling. I usually use a different method which in the end makes it more convenient for this, but you can think about it this way. I'm going to assume you have been setting your jump variable to two to allow double jump. This means if you are falling when the jump variable is still two, then that means you fell from a platform (so you should set jump to zero). But if you are falling and jump is equal to one, that means you jumped to get there. Here's a way to determine if the actor is falling.
player -> Draw Actor -> Script Editor
Code: Select all
if(yvelocity>3) // you can change 3 to make it suit your game better
{
    // falling (you want to set jump to 0 if and only if jump is equal to 2
}

Re: Jump after falling off platform

PostPosted: Mon Feb 20, 2012 2:28 am
by SuperSonic
skydereign wrote:if(yvelocity>3) // you can change 3 to make it suit your game better

1 is the number that suites me best :D

Re: Jump after falling off platform

PostPosted: Mon Feb 20, 2012 11:39 pm
by badchad024
Thanks that fixed the problem! :D