• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Wall jumping

S

Soco

Guest
I got a wall jumping character in my game, but he is able to wall jump while he's falling simply by pressing the opposite direction key. Which I'd like him to not be able to do...I thought my code would be quite simple, but it's not working and I'd like it to work. =) This is what I've come up with so far and when I add a show_debug statement to see my "falling" variable, it always says 0...falling is always coming back as true. The problem must be with the "falling" variable not reading correctly?

Code:
//Movement
var falling = y-yprevious > 0;
show_debug_message(string(falling));
if (right) {
    hspd += acc;                            
    hspd_dir = right - left;              
    face = RIGHT;                        
    if (hspd > spd) hspd = spd;  
    if (hspd < -spd) hspd = -spd;
    //Wall Jump
    if (!falling){
        if (place_meeting(x-1, y, obj_Solid) && !place_meeting(x, y+1, obj_Solid) && !left) {
            vspd = -16;
            hspd +=acc;
        }
    }
}else{
if (left) {
    hspd += -acc;
    hspd_dir = right - left;
    face = LEFT;
    if (hspd > spd) hspd = spd;
    if (hspd < -spd) hspd = -spd;
    //Wall Jump
    if (!falling){
        if (place_meeting(x+1, y, obj_Solid) && !place_meeting(x, y+1, obj_Solid) && !right) {
            vspd = -16;
            hspd += -acc;
        }
    }
 
B

Becon

Guest
Try something like this:

Code:
var falling = false
if y-yprevious > 0
    {
    falling = true
    }
else
    {
    falling = false
    }
Then in your code add something like

Code:
if falling = false
    {
    do your wall jump code
    }
 
D

dCoder

Guest
I think I'd do it something like so

Code:
in step of player/character:
var canJump = true;
var fallingSpeed = 15 ; // just an example you want real gravity calculation here

y+=fallingspeed; // just standard falling code

//check if player has collisio with wall
if(collisionWidthWall){
     fallingSpeed = 5;// slowing down the fall you can add your on wall logic here
     canJump = true;
}
// check if player is on the ground;
if(onGround){
   canJump = true;
   fallingSpeed = 0;
}
this is ment to give you an idea on how you can make it workk, this is in no way copy paste working code.
 
Top