How can I make it where I automatically move in a certain direction (Purpose is for wall jump)

19 Views Asked by At

I am trying to add a wall jump to my game and am struggling with the horizontal momentum, where it just teleports to the location instead of it being a smooth arc.

var move = key_right - key_left;

//horizontal collision
if (place_meeting(x+hsp,y,oWall)) {
    while (!place_meeting(x+sign(hsp),y,oWall)) {
        x = x + sign(hsp);
    }
    hsp = 0;
    if (!place_meeting(x,y+vsp,oWall)) {
    walltouch = true;
    }
}
else {
walltouch = false;
}

//vertical collision
if (place_meeting(x,y+vsp,oWall)) {
    while (!place_meeting(x,y+sign(vsp),oWall)) {
    y = y + sign(vsp);
    }
    vsp = 0;
    inair = false;
}
else  {
inair = true;
}

//wall jump
if (inair) && (walltouch) && (key_jump) {
vsp = -15;  //vertical momentum
hsp = -30 * move;  // horizontal momentum
}
0

There are 0 best solutions below