#How to restrict rotation that is based on Global Mouse Position?
1 messages · Page 1 of 1 (latest)
In this situation, it may be easier to calculate the angle yourself, then clamp it to the range:
var change = get_global_mouse_position() - global_position
var angle = atan2(change.y, change.x)
angle = wrapf(angle, 0, 2 * pi)
rotation = clamp(angle, pi, 2*pi)
You may need to adjust the clamp range based on the pointer sprites default direction.
You could also potentially do:
var point = get_global_mouse_position()
point.y = min(point.y, global_position.y)
look_at(point)
Assuming look_at was giving you good results.
So the 1st one made it so the movement was very clunky
And the 2nd one only lets it face 180 or 0