0 votes

Say there is a tileset for making cliffs. The player can stand on top of the platforms of these cliffs, like so:

However, the player should also be able to walk behind the cliff, like so:

The problem is, that the collision of the tileset will prevent the player from entering the area behind the cliff. I spent several weeks searching for the solution and couldn't find any, how does one solve this problem?

(Sorry if the images don't show up, this is my first time trying to post them here, so it might not work)

I'll try to provide more specific information if necessary.

Godot version 3.2.3
in Engine by (92 points)

1 Answer

0 votes

I haven't tested this myself, but check these similar questions:



So basically:
if player.z_index > cliff.z_index: (Player will be drawn in front of (on top of) the cliff)
And vice-versa.

I suppose what you can do is put an Area2D node behind the cliff, and when the player enters it, his z_index is lowered so that he can walk behind (under) the cliff.

Otherwise, player.z_index should be higher than cliff.z_index, so that he can walk on/up it.
You could also use a YSort node, as mentioned in those posts.

by (236 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.