Legacy GM Passable Stairs/Slope



Hi folks,

I've been racking my brains for the past few days, I'm working on a platform game which involves stairs to move up and down a building, but be able to explore each floor. I can get slopes to work to act as stairs, but then I want to be able to walk past the top and bottom of stairs to explore either side.
Picture below shows what I mean:

The basic concept I'm thinking of is that when the player collides with the stairs while pressing up/down (whilst moving left/right) it will then allow them to move up/down accordingly but I can't figure out a method to make it work.

As mentioned before I've tried slopes but can't figure out how I would pass through them.

I've looked into turning it into a 'ladder' at an angle but I can't figure that out, most tutorials I've seen for that show the player going through the ladder on either side once they climb up, obviously I don't want the player to phase through the steps whilst going up/down.

My other thought would be if the stairs have a different depth and the key press to go up/down would allow the player to switch to that 'layer', which would maybe be quite achievable. With this approach though I would think it will interfere with combat elements, as in the player might press up/down to phase through to that other 'layer' and dodge enemies. It would be ideal if enemies could use these stairs also.

I hope this makes sense, I'm not looking for the code, I'm currently learning gml and want to figure the actual code out myself, I just want to know which approach would be the most effective way, or if there's something I've missed.

Thanks in advance!




did you tried to use finite-state machines?
in the "onGround" state you can check if there is a stair where you pressed up/down, and then change the "onStairs" state


No I haven't tried that, sounds like a good idea so thank you, it'll also come in handy programming the enemy AI! I'll post an update with my results tomorrow!


Just a quick update, had a thought this morning regarding my stair issue, then thought about the actual design of the stairs themselves. In most large houses, factories etc you wouldn't have just straight staircases, most of the time they would have a bend/right angle particularly if they follow the boundary walls of a structure. This got me thinking about gameplay, and that my initial concept of stairs is slightly flawed because at what point do you press up/down to access them and how would the player know this without prompts. So i mocked this up:

A slightly more elegant solution i think, the stairs span the width of the room as a slope, using 'ladders' at either end to connect the slope to the floors.
It also adds a bit more depth to the room as well. I'll see how I got on with the previous mentioned method and also this method, see which works best and then post the code up here.

What do you folks think of this solution?
Last edited by a moderator:


You press up/down when you're at the foot of the stairs... Do you need a special prompt to tell you, "Hey, there are stairs to your left - you can climb up now," just to go to the second floor of a building?

In all seriousness though, I'll just bring up NES Castlevania stairs. Stairs themselves don't exist in those games. You have an invisible object (we'll call it obj_Landing) placed wherever stairs start and end. You set in obj_Landing's Creations Code which direction it goes (up-right, up-left, down-left, or down-right). When the player pushes up, you look for any obj_Landing set for up; likewise for when the player pushes down. If the player is at the same height and within 8 pixels of a matching obj_Landing, you set the player's state to walk_to_stair, set an alarm for how far away the obj_Landing is (abs(x-stair's x)), and make the player walk to it. When the alarm reaches 0, you change his state to climbing_stairs and make him move in the direction of the landing. Set a variable in the player so he knows whether he's climbing up-left or up-right. Getting off stairs is essentially the same.
Last edited: