I have set up a detector to detect when the player moves through an area. I'm using an Area2D with CollisionShape2D and a "body_exited" signal on Area2D. This works wonderfully, until I try to place the detector as a child of a ParallaxLayer node.
I'll set up the scene: I have a Node2D as the root node (we'll call it Root), then a ParallaxBackground node with a ParallaxLayer as a child. The ParallaxLayer has a child Sprite which contains the ground/background texture.
| -> ParallaxBackground
|| -> ParallaxLayer
||| -> Sprite
| -> Player
| -> GroundHitbox (ignore)
| -> PlayerDetector [Area2D] (1 connection)
|| -> CollisionShape2D
When the detector is a child of Root (as it is above) it works perfectly. It will print a message ("player exited left/right") when the player exits the detectors CollisionShape2D.
However, if I place the detector as a child of the ParallaxLayer (or it's child Sprite) the detector's detection area will be offset (i.e. the message will be printed when the player moves through an area to the left of the actual detector, but will do nothing when the player moves through the actual CollisionShape2D area.
The offset is amplified the farther away the detector is placed from the origin.
The detector works correctly when placed as a child of the ParallaxBackground node instead of the ParallaxLayer Node.
Is this a bug, or an incompatibility with ParallaxLayers? Or am I doing something wrong?
- The ParallaxLayer is not scaled at all and the ParallaxBackground has a BaseScale of 1 (basically no paramaters changed)
- My goal is to get an infinite background by using two copies of the background Sprite and then "leapfrogging" them over each other to create the illusion of an infinite world. The detectors are meant to trigger this action. The reason for using ParallaxLayers is that I wish to do this for each of my parallax layers.