bananapantsu88
Member
Hello, I have this problem where my player can jump twice after he fell off a cliff. I've programmed my character so he can double jump using "jumps" and "jumpsmax" has statements as the numbers of jumps allowed and the numbers of jumps remaining respectively.
I allowed my player so he can only jump two times before the numbers of "jumpsmax" equals 0, implying that the number of jumps remaining equals 2 while on the ground. I need to find a way to allow the player to only jump once once he is in the air after he fell off a cliff, implying that I need the numbers of jumps remaining ("jumpsmax") to be 1 once the player fell off a cliff so he can only jumps once once in the air.
Here is the chunk of code about the "Jump Status".
onground variable meaning place_meeting(the floor) (on Create event "onground = false", on Step event "onground = place_meeting(x,y+1,oWall);" oWall is the object I use to the floor and the wall, because it's an invisible block in-game.
jumps variable meaning numbers of jumps remaining (on Create event "jumps = jumpsmax;")
jumpsmax variable meaning numbers of jumps allowed (on Create event "jumpsmax = 2;")
Also, when I mean when my player fell off a cliff, I mean when you as the player just simply run and fell off because there's no more floor below him.
I think there's no more info necessary to address my problem. If anyone knows the solution about this problem, please let me know, I would be really grateful.
I allowed my player so he can only jump two times before the numbers of "jumpsmax" equals 0, implying that the number of jumps remaining equals 2 while on the ground. I need to find a way to allow the player to only jump once once he is in the air after he fell off a cliff, implying that I need the numbers of jumps remaining ("jumpsmax") to be 1 once the player fell off a cliff so he can only jumps once once in the air.
Here is the chunk of code about the "Jump Status".
Code:
#region Jump Status
if (onground == true) //onground jump
{
jumps = jumpsmax;
}
if (key_jump && jumps > 0) //on air jump
{
jumps -= 1;
if (key_jump) vsp = -jumpsp; //jump velocity
if (onground) audio_play_sound(snJump1,1,false); //set audio sound when on ground jump
if (key_jump && !onground) //set audio sound when not on ground jump
{
audio_play_sound(snJump2,1,false);
}
}
if (vsp < 0 && !key_jump_held) vsp = max(vsp,-2); //change jump velocity while not helding key jump
#endregion
jumps variable meaning numbers of jumps remaining (on Create event "jumps = jumpsmax;")
jumpsmax variable meaning numbers of jumps allowed (on Create event "jumpsmax = 2;")
Also, when I mean when my player fell off a cliff, I mean when you as the player just simply run and fell off because there's no more floor below him.
I think there's no more info necessary to address my problem. If anyone knows the solution about this problem, please let me know, I would be really grateful.
Last edited: