2D Platformer Help - Dash State Collisions


So I have been developing a 2D Platformer in GMS2 and I wanted to add a dash state similar to how the Knight dashes in Hollow Knight.

I got a basic set-up going with different player states, but I will only be providing the dash state code. Mind you, I'm a beginner in GMS2 and game design in general so most of my programming skills revolves around logic-based strategies, which means my code isn't super complex.

My issue:
  • The code works fantastic, aside from...
    • Player gets stuck in a wall when colliding from the right side of the wall, however the player does not get stuck in the wall when colliding from the left side of the wall.

Important things to note:
  • Player movement and collision code is located in the player's free state. Works great, so that shouldn't be the issue.
  • Player controls are disabled during the dash state.
  • This doesn't seem to be an issue with the player's base collision code in the free state, considering colliding with the wall in the free state works as intended. It's only when I collide with the wall in my dash state.
// STEP CODE (Dash State)

#region // Horizontal Collisions

if (place_meeting(x+hsp,y,oWall)) // Wall Check

    while (!place_meeting(x+sign(hsp),y,oWall))
        x += sign(hsp);
    hsp = 0;


x += hsp * dir; // Movement


#region // Dash Code

//dash_timer is set to 10, represents how long the player is dashing.

if(dash_timer > 0) // Dash timer starts at 10.
    hsp = 16; // Set horizontal speed to 16.
    dash_timer--; // dash_timer subtracts by 1 each step.
else if(place_meeting(x+hsp, y, oWall) || place_meeting(x-hsp, y, oWall) || dash_timer = 0)
    //Basically, if I collide with a wall or the dash timer runs out, run the code below.
    hsp = 0; // Set horizontal speed equal to 0;
    dash_timer = 10; // Reset dash timer.
    state = PLAYERSTATE.FREE; // Change player's state back to free (player gains control again)


Let me know if you guys can figure this out. It seems like such a simple fix but I just can not get it working for the life of me.

Last edited:

I figured out the issue and it was so simple.

I removed the "*dir" from the horizontal collisions code and added it to the speed of the dash and things worked perfectly fine.