I
IcyZ1ne
Guest
So I am trying to make my character to double jump, but I either make him only jump once or jump for as many times as they want. Here is my code:
jumps = 0;
jumpsmax = 2;
if(onGround)
{
jumps = jumpsmax;
}
if(jump && !jumpHold && jumps > 0)
{
jumps -= 1;
ySpeed = jPower;
squash_stretch(0.7,1.3);
}
With the code above my player only jumps once.(perhaps that when you are no longer onGround jumps goes back to 0?)
And here is the code that somewhat works, but makes my player jump forever :
jumps = 0;
jumpsmax = 2;
if(onGround)
{
jumps = jumpsmax;
}
else
{
jumps = 1
}
if(jump && !jumpHold && jumps > 0)
{
jumps -= 1;
ySpeed = jPower;
squash_stretch(0.7,1.3);
}
Please help me out to make it work properly! Thank you.
jumps = 0;
jumpsmax = 2;
if(onGround)
{
jumps = jumpsmax;
}
if(jump && !jumpHold && jumps > 0)
{
jumps -= 1;
ySpeed = jPower;
squash_stretch(0.7,1.3);
}
With the code above my player only jumps once.(perhaps that when you are no longer onGround jumps goes back to 0?)
And here is the code that somewhat works, but makes my player jump forever :
jumps = 0;
jumpsmax = 2;
if(onGround)
{
jumps = jumpsmax;
}
else
{
jumps = 1
}
if(jump && !jumpHold && jumps > 0)
{
jumps -= 1;
ySpeed = jPower;
squash_stretch(0.7,1.3);
}
Please help me out to make it work properly! Thank you.