0 votes

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.

Root [Node2D]
| -> 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?

Additional Info:
- 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.

in Engine by (14 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.