How do I add walls to a parallax background?

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

The game I am currently working on, is meant to be infinitely scrolling vertically, but with a fixed width. I need to however, prevent players and mobs from leaving this horizontal plane. I tried adding StaticBody2D nodes as children of the parallax layer and setting their collision shape to rectangle, which semi-worked. The problem was, that this method led to some gaps in between the walls that the player could pass through. I scaled the collision shape to be the same size as the mirroring of the parallax background but still had this problem. I even scaled the collision shape to be larger than the mirroring of the parallax background, however it still did not work.
I’m really not sure what else I could do.

:bust_in_silhouette: Reply From: A112

Try adding your StaticBody2D to the root of your scene, so they never move. Make sure to use matching mask/layer configuration.