+2 votes

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?

Godot version 3.5.1
in Engine by (36 points)

1 Answer

+1 vote

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.

by (3,321 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.