if the current degrees of rotation are, for example, 90 and I need to rotate to 0 degrees of rotation, I need the object to rotate to the left, because this is faster than if it rotated to the right. How to determine which direction it is spinning in order to reach the desired degree measure as quickly as possible?

in Projects

So what you're asking is more of a math problem. I'm not really good at visualizing stuff like this, but maybe an answer here could help. I don't think you need to know the direction the object is currently spinning in order to find the fastest path there.

by (1,812 points)

There's a few ways of doing this but the easiest way for a single axis is to check if the end rotation is above or below the starting rotation by 180 degrees and add or subtracting 360 degrees.

``````if wanted_angle > rotation_degrees+180:
wanted_angle -= 360
elif wanted_angle < rotation_degrees-180:
wanted_angle += 360
``````
by (3,145 points)
``````if self.get_angle_to(target.global_position) != 0: