mouse_entered() and mouse_exit() only working at the very start of the scene

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By vermilion_godot

For some reason, my mouse_entered() only emits when the scene just starts up. This is what my scene tree looks like.
Scene Tree

I’m unsure if there’s something that needs to be changed somehow. The following is my code for handling the signals.

extends RigidBody

export var obtainable = true
export var quantity = 1

var mouse_over

signal picked_up(object, obj_quant)

func _input(event):
	if Input.is_action_pressed("pickup"):
		print("pickup attempted")
	if mouse_over and Input.is_action_pressed("pickup"):
		print("picked up")

func _on_Selection_mouse_entered():
	mouse_over = true

func _on_Selection_mouse_exited():
	mouse_over = false

My pickup input works fine and it is running. It’s just the mouse_entered() and mouse_exited() that are not working. Here are the signals from the Selection Area node.

:bust_in_silhouette: Reply From: Ertain

Your RigidBody node could be intercepting the mouse_entered() and mouse_exited() signals; check to make sure the node isn’t capturing the signals.

So it looks like it switches between the RigidBody and the Area nodes. How would I solve this if I wanted to have a separate Area for the selection hitbox?

vermilion_godot | 2020-05-24 06:41

The input_ray_pickable property of the RigidBody may have to be toggled on and off when the mouse enters the Area. Either that, or make the CollisionShape of the Area larger than the CollisionShape of the RigidBody.

Ertain | 2020-05-24 19:09

Ahhh. I didn’t think of turning off input_ray_pickable on the RigidBody. The problem persists if the Area shape is larger than the RigidBody shape. Thank you so much for the help!

vermilion_godot | 2020-05-24 22:04