get_local_mouse_position rotation confusion

Godot Version

4.6.2

Question

I am confused about get_local_mouse_position(). get_local_mouse_position() gives me different results based on the rotation of the Node2D. This is confusing to me. It means that the local position of the mouse can change even if the user doesn’t move the mouse. Is it possible to make get_local_mouse_position() stop doing that?

Here’s some example code that reproduces the issue:

extends Node

# Delta Unit: Seconds 
func _physics_process(delta):
	var center = get_node("Center")
	var label = get_node("Label")
	label.text = "get_local_mouse_position() Result: " + str(center.get_local_mouse_position())
	var center_rotational_speed = 1  # Unit: Radians/Second
	center.rotation = center.rotation + center_rotational_speed * delta

Or here’s a video that shows the issue:

get_global_mouse_position

vs.

get_local_mouse_position

Global gets the position relative to the Canvas. That should not change.

Local gets the position relative to the CanvasItem. If the item moves and the mouse position does not this will change.

What @that_duck said should be enough.

But just in case you actually know what local and global position means, maybe you are confused that, when the object rotates, it’s origin is still staying same. But your mouse position is still moving with respect to object.

The x-y axis of the object also rotates. And the same point (orange cross) for that axis changes with respect to the screen.