0 votes

I have an Area2D with child node CollisionShape2D with shape RectangleShape2D. For some reason, the the mouse_entered signal is only sent out when I have all ParallaxLayers hidden. The Area2D is below the layers in the hierarchy. I tried changing the z-index but it didn't work. How do I get the mouse_entered signal to work without hiding the background?

in Engine by (6,496 points)

What is the order of nodes in scene tree?
Is Area2D above or below the parallax layers?

Here, let me quote that for you.

The Area2D is below the layers in the hierarchy.

My bad, I couldn't see that.

Anyway I made some tests and with Area2D as lowest node it seems to work, maybe it is necessary to check the parenting of the node.

  • Node

    • ParallaxBackground

      • ParallaxLayer1
      • ...
      • ParallaxLayerN
    • Area2D

      • CollisionShape

This works for me, but maybe your scene is more complex than this.

Nope, that's how my scene is set up too.

I see. If any other detail comes to your mind, please share as it may help in finding a solution.

Maybe I should be more specific.
I'm trying to get a parallax background to scroll when I move my mouse to the edge of the screen, so I have two area2ds on either side of the screen.
The layout looks like this:

  • Node2D

    • ParallaxBackground

      • ParallaxLayer

        • TextureRect
    • CanvasLayer (so the Area2Ds don't move with the background)

      • Area2D

        • CollisionShape2D
    • Camera2D

I have a script on the Camera2D that is connected to the mouse entered and mouse exited signals on the area2ds.
For some reason, when I first play the scene, the signals don't seem to work. But I also have the Camera set to scroll with keyboard inputs. So if I use the keyboard inputs to scroll the camera, the signals work. But only the Area2D on the right of the screen scrolls the camera, even though the code for scrolling the screen to the left and the right is the same. Also the mouse exited signal for the left Area2D is sent out right after the mouse entered signal even if I haven't actually moved my mouse out of the area.

I'm really confused.

1 Answer

0 votes
Best answer

Turns out the TextureRects were eating the mouse events. Set the mouse filter to ignore to fix this.

by (6,496 points)

Thanks self, great answer

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 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 webmaster@godotengine.org with your username.