How do I handle 2D physics objects in parallax depth?

Godot Version

4.6.2 stable mono

Hello everyone. I’m currently working on a 2d game where player can go from the main tilemap to a tilemap layer located in Parallax2D
layer, to create a fake 3D depth effect. The problem I’m facing is that I do not know how to enable or disable collisions of all possibles physics bodies and area2Ds that are child of the depth layer, so that I do not interact with them when player stands on the main layer.

In 3D depth is “automatic”, but how can I achieve such results in 2D ?!

Here are the examples :

Mario → Mario Wonder
Donkey Kong → Donkey Kong Country Returns Wii

The easiest way would be to put the background on a different collision layer, and then just change which one the Player is on.

1 Like

I have thought about this, and I have a solution to handle that, but what about the enemies ?

Same solution.

1 Like

I’m currently experimenting that, and it looks quite promising, except for AnimatableBody platforms that works weirdly …

They are also have physics collision layers. They should be fine.

1 Like