How to enable player to walk behind tilemaps with colisions?

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

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.

:bust_in_silhouette: Reply From: Error7Studios

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

https://godotforums.org/discussion/22294/best-methods-for-displaying-trees-in-front-or-behind-the-player

https://forum.godotengine.org/43069/how-to-make-a-character-sprite-hidden-behind-wall-in-tilemap

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.