Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | gm130993 |
the tittle says it all
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | gm130993 |
the tittle says it all
Reply From: | jgodfrey |
Depending on the details, you might be after fmod()
. For example:
func _ready():
for deg in [0, 250, 359, 360, 400]:
deg = fmod(deg, 360)
print(deg)
prints…
0
250
359
0
40
If you also want to push negative angles back into the 0-360 range, you can just add an additional check after the fmod
call. Something like this:
deg = fmod(deg, 360)
if deg < 0: deg += 360
Reply From: | CassanovaWong |
maybe:
rotation_degrees = clamp(rotation_degrees, 0, 360)
or
rotation_degrees = wrapf(rotation_degrees, 0, 360)
or, as an integer,
rotation_degrees = int(rotation_degrees)%360