+1 vote

I have a GDScript that displays a tooltip when hovering the mouse over an item. The Item scene extends Area2D and connects the mouseentered / mouseexited signals to show / hide the tooltip. Here's what's happening:


I've noticed that it consistently happens (to some of the items) when standing on certain positions, but can't figure out why. I have a Player scene with a Camera2D child (the current camera) with default settings.

The item sprites have an outline shader, but the issue still happens without it.

Here's the signal's code:

func _on_Item_mouse_entered():
    ui.offset = get_global_mouse_position()
    ui_container.visible = true
    tween.interpolate_method(self, "set_shader_border", 0, 2, 0.1)

func _on_Item_mouse_exited():
    ui_container.visible = false
    tween.interpolate_method(self, "set_shader_border", 2, 0, 0.1)

Any ideas?

Godot version 3.3.stable
in Engine by (16 points)

make sure input_pickable is enabled on those Area2Ds

yes, it is :/

Oh wow I just looked at the video. Can you post your node structure? What node is this script attached to? And just out of curiosity what is ui.offset used for?

Sure. The script is attached to the Item node (see image).


ui.offset is used to reposition the tooltip (onready var ui = $HoverUI), since I have it on a CanvasLayer (I may have to rework this and read a bit more about CanvasLayers, the idea was to prevent the tooltip from being affected by the world's lights and visual effects. The issue still happens without changing the offset though.)

Here's the whole Item.gd in case it's useful: https://pastebin.com/NREGXB21

That is definitely some strange behavior. I don't really see you doing anything out of the ordinary in the code. Have you tried adding print() statements to the methods to see if they fire? This would isolate it to either a signal notification thing or a graphical thing.

OH! I have had behavior like this before. It was with two control nodes being drawn on top of each other though. The one underneath would eat the input and it wouldn't be propagated to the one on top. Could something similar to that be happening here? Try setting the mouse_filter property of your control nodes to Ignore

That was it! I had a RichTextLabel on top of the player's head for displaying chat messages. That's what was eating the mouse_entered signal. Changing the mouse_filter property to Ignore fixed the issue. Thanks a lot!

No problem! That one got me for a few hours when it happened to me hahaha! Glad I could save you the time.

1 Answer

+1 vote
Best answer

There was a RichTextLabel on top of the player's head that was consuming the mouse_entered signal from the Area2D. Changing the mouse_filter property to Ignore resolved the issue.

by (3,389 points)
selected by
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.