• Godot HelpProgramming
  • Function- func _unhandled_input(event) not working with a knot that is attached to the mouse.

Trying to use the function :

    func _unhandled_input(event):
    	if event is InputEventMouseButton:
    		if event.button_index == BUTTON_LEFT:
    			if event.pressed:
    				print("Left button was clicked at ", event.position)
    			else:
    				print("Left button was released")
    		if event.button_index == BUTTON_WHEEL_DOWN:
    			print("Wheel down")

but when I have a node attached to the mouse it doesn't work.

    func _process(delta):
        tile_build.position = get_global_mouse_position().snapped(snap)

Maybe another node, like a Control node, is catching the input and so _unhandled_input isn't getting the input events? Does using _input(event) with the node attached to the mouse work?

If some other object has captured the input, it won't propagate to other nodes. Look in the mouse filter option of the node (usually for control nodes) you can set the mouse property to pass or ignore. You can also use a different method of checking mouse input. For example on _input() or manually using Input. It's probably a good idea to use an input mapping rather than parsing raw events. https://docs.godotengine.org/en/stable/tutorials/inputs/inputevent.html

a year later