Hey there!

I am trying to make a generic function to rotate an object a given angle. The problem is that when the “TargetRotation” = “InitialRotation” + “DeltaRotation” > 180, the object starts spinning without stopping.

Logging in the console the current rotation of the object I’ve realized that it goes from -180 to 180 degrees and then resets, so obviously it will never reach that “TargetRotation” when is greater than 180 or less than -180 degrees.

I’ve tried checking if this “TargetRotation” is greater than 180 and decreasing it by 360, then calculating how many total rotations would be needed, but it doesn’t seem to work.

Is there any way to overcome this and get a function that rotates an object a given angle around one axis?