How can I change the Layer mid game?

Godot Version

4.3

Question


How can I change the layer so that when I walk behind it the board gonna go to the upper layer and when i walk infront of it the board is behind the player?

1 Like
func change_to_layer(x : int) -> void:
         MyGuy.visibility_layer = x

you can do this with anything that extends the canvasitem class, which is virtually everything in 2D :slight_smile:

For this use case, enabling y sort is probably a simpler way to get what you want.

2 Likes