Placing a Label at the center of a 2D-window with the following code does not give me the angle I expect. It's obviously me not understanding something, so I would appreciate if someone could point me in the right direction.
extends Label
func _process(delta):
var angle_to_mouse = get_rect().position.angle_to(get_local_mouse_position())
text = str(rad2deg(angle_to_mouse))
What I expected was an angle of ~0 when the mouse pointer is to the right of the label, and 180 degrees when to the left.
What I get is 0 degrees when the mouse pointer is below and to the right of the label, and 180 degrees when the pointer is up to the left of the label, i.e. towards (0,0). Straight to the left of the label its at 150 degrees and -30 degrees straight to the right.
Why is is?
Thanks in advance,
Per