system
1
|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
ManiCus |
func get_mouse_rotation():
$rot.look_at(get_global_mouse_position())
print($rot.rotation_degrees)
While rotating the node $rot, the it keeps adding numbers in and not going from 360 to 0.
system
2
|
|
|
|
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)
$rot.look_at(point)
print($rot.rotation_degrees)
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