Rotation_degrees kepps adding up (???)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ManiCus
func get_mouse_rotation():

While rotating the node $rot, the it keeps adding numbers in and not going from 360 to 0.

:bust_in_silhouette: Reply From: Wakatta

Use a clamp if you don’t want it to move

func get_mouse_rotation():
    var point = clamp(get_global_mouse_position(), 0, 360)

Actually I think wrapf would work better for your use case

Wakatta | 2021-06-18 23:58

or an fmod()

rotation_degrees = fmod(rotation_degrees, 360)
rotation = fmod(rotation, 2 * PI)

But the question remains. Why does it keep accumulating in both directions?

wyattb | 2021-06-19 01:07