When clicking on a building sometimes the UI of the building behind opens. It seems like the Event is not consumed properly.
Try something like:
func _unhandled_input(event): if event is InputEventKey and event.pressed and event.keycode == KEY_SPACE: print("Space key pressed!") event.consume() # Stop other _unhandled_input handlers in the same viewport from receiving this event
or
func _unhandled_input(event): if event is InputEventMouseButton and event.pressed: print("Viewport handled the click.") get_viewport().set_input_as_handled() # Prevent this event from propagating to other nodes or viewports
When clicking on a building sometimes the UI of the building behind opens. It seems like the Event is not consumed properly.
Try something like:
func _unhandled_input(event): if event is InputEventKey and event.pressed and event.keycode == KEY_SPACE: print("Space key pressed!") event.consume() # Stop other _unhandled_input handlers in the same viewport from receiving this eventor
func _unhandled_input(event): if event is InputEventMouseButton and event.pressed: print("Viewport handled the click.") get_viewport().set_input_as_handled() # Prevent this event from propagating to other nodes or viewports