Hi, I want to connect a mouse_entered and mouse_exited signal to respective functions.
I have this :
extends Area2D
func _ready():
if has_signal("mouse_entered"):
connect("mouse_entered", _on_mouse_entered)
if has_signal("mouse_exited"):
connect("mouse_exited", _on_mouse_exited)
func _on_mouse_entered():
print("plop")
func _on_mouse_exited():
print("zblurg")
I don’t have any error, and it does go through the conditions.
The script is attached to an Area2D node with a CollisionPolygon2D child node. I changed only its position since I added this node
ChatGPT and documentation would let me think what I’ve done should work, but I guess not. Anyone ?
So… I detached and deleted the script. Created a new one, didn’t rename it (we never know, i’m new to godot), connected the mouse_entered signal with itself through the Node tab and still doesn’t do anything. The Area2D has a simple rectangle collision shape as a child and it has pickable on true.
Does it show the green arrow icon to the left of the function? Do you have your area positioned somewhere where your mouse actually enters and exits your collision shape?
Do you have this icon (circled in red) enabled, and is it not greyed out?
If it looks a little greyed out compared to this, just click on it.
I just tried what you said you did, and it works just fine. If you could take screenshots of your entire Godot application in 2D view, I might be able to identify something.
Edit: Tried to put the Area2D node at the root
Edit2: I’m currently using mouse_entered signal on panels and works fine. I must miss something about Area2D nodes
I don’t know why it doesn’t work BUT whatever I want to do, I realized I can do it with panels instead of areas. Areas is more for collision which I don’t use.
Thanks for your help, it’ll still be a mystery (to me at least) but w/e I guess it was more a bad choice of node (for what I need to do) than anything else.