GMS 2.3+ Collisions with objects + sliding on walls

Hi everyone.

I'm trying to make collidable objects, of many different types.
For now, I'm using walls as a test case.

What I want to do is this:
the player should collide with a wall object and still be able to move except where there is a wall.

This is the setup (that can not change):

1) The player is not flagged as solid
2) The wall object is flagged as solid
3) walls are only vertical or horizontal, no diagonals
4) Input controls are stored in a controller object under global variables and are updated every step
5) when the player pushes a direction input key, the player object moves in up to 8 directions, per pixel (x+1, y+1,...)
6) "Stopping" the player by a collision happens with a collision event, in this case the player gets a collision event (with a wall object)

So far this works, but whenever i do diagonal movement against a wall, the player gets "stuck".
I understand why this is, but I don't understand how to solve it with my setup.

What I want to do, is have code in THE COLLISION EVENT (in the player object: collision event with OBJ_Wall),
that makes it so the player can neatly "slide" along a wall.

So, if a wall is to the right of the player, and the player collides with that wall on the right while moving diagonal up/down and right,
then the "right" input must be ignored and only up and down (and left) can still work.

I've tried and tried, with this setup, but haven't figured it out.

Extra info:
I will not use tile collisions, it has to be object based.
I will continue with the setup described above, and need a solution within this setup only (no alternatives please).

Basically I'm trying to find a quick solution given this setup. It seems like the kind of thing that should be easy,
but I guess it's not.
 

Nidoking

Member
So, effectively, in the collision event, if the direction is diagonal, you want to check each of the two orthogonal directions and see whether movement in one of those directions is possible, and if so, do the movement. Right?
 

Nidoking

Member
Okay. Then I think this person has given you the answer.

So, effectively, in the collision event, if the direction is diagonal, you want to check each of the two orthogonal directions and see whether movement in one of those directions is possible, and if so, do the movement.
 
Top