Why isn't _unhandled_input() triggering when I move the mouse?

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

I can create a node on its own with the following code:

func _unhandled_input(event: InputEvent) -> void:
	if event is InputEventMouseMotion:
		print("mouse moved")
		print(event.speed)

and have it work and giving me the following output when I move the mouse:

mouse moved
(-1238.743164, -463.655518)
mouse moved
(-1238.743164, -463.655518)
mouse moved
(-1238.743164, -463.655518)
mouse moved
(-2783.995117, -1634.93042)

but when I paste this exact same code into my player script, it only triggers when I run the player scene on it’s own with F6, but running the game with the main scene (F5) with the player in it it never triggers. I have already checked if I have used the function "set_input_as_handled()" somewhere in another script with Ctrl+Shift+F, and there is none.

Any help much appreciated. Thank you.

Could there be some node consuming the mouse movement? If there are any Control nodes in the scene, check their “Mouse” property and see whether the property is set to “Ignore” or “Pass”.

Ertain | 2021-09-07 22:41

You are right! When I delete my UI it is working! So now I just need to isolate which specific node it is. Thank you!

nincompoop | 2021-09-08 09:00

If you have many nodes which could consume the input, you can go to Debugger paneMisc.Clicked Control to see which node consumed the mouse input last.

Ertain | 2021-09-08 17:31