Is it possible to implement stairs like this?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JCJL

I’m currently making a game where enemies can follow the player throught multiple floors on a 2d platformer-like level, but i cannot get around how i would do something like this, i would like fo the player to be able to walk under the stairs and be able to go up, but so can the enemies, like this:

I cannot figure out how to make it work for the player yet, let alone the enemies following the player down or up the floors of the levels.
Is there an easy way to do this or should i think of a different way of enemies following the player down or up the floors?

:bust_in_silhouette: Reply From: Gluon

A lot of questions in here! I will answer the first question which i guess is how you would get the player to behave in a way where they can go up or go through the stairs. What you want is an area2d.

If you have an area 2d right at the bottom of the stairs you can have some code in the player node which would say something like if the player is in the area2d and both left/right and up are pressed then the player goes up at an angle (i.e. you add a y and x vector to the players character to go at an angle).

If however only the left or right is pressed the player will only get an x vector.

The stairs themselves will be a graphic but cannot have a collision layer associated so you will need to ensure the characters animation when going up at an angle makes it look as though they are going up the stairs even though they will not be touching any actual collision points.

Hope that helps.

1 Like