On the top level I have a Node2d
where I want to capture the mouse position on a click event. However, something is messed up and I have no clue what. The following GDScript is attached to the node.
extends Node2D
func _unhandled_input(event):
if event is InputEventMouseButton:
print(event.position)
# (514, 309)
print(event.global_position)
# (514, 309)
print(get_global_mouse_position())
# (1, 4.5)
If I click close to the center (0, 0) I get for event.position
and event.global_position
coordinates which are totally off. However, get_global_mouse_position()
works fine.
All properties for the node are on default. What could cause such behaviour?