About threshold:
In your case, this is not the threshold.
For example, you want to rotate from 0 to 90 degrees, with a threshold of 8 degrees.
Your code will stop at 82 degrees, not 90 degrees, as you expect it.
About the compass:
I reread all your posts in the thread, and I think there is a misunderstanding.
Heading of the compass is just a value from 0 to 360.
The device’s sensor does not return the direction of change (clockwise or counterclockwise).
The device’s sensor has an update period of 0.02 - 0.2 seconds (usually 0.06).
If you can rotate the device more than 180 degrees in 60 ms, my congratulations - you are flash.
About animation:
By quickly rotating the device, you may not have time to animate the rotation.
In other words, while the animation is in progress, you can get the difference between rotation of the marker and the compass value of more than 180 degrees, and the animation will go in the opposite direction.
It is very easy to prevent this - if the difference between the previous and current compass value is more than 180 degrees, add or subtract 360 degrees to normalize the transition through 0.
This will give you values of -90 degrees or 457 degrees, which is outside the range of 0-360, but it is absolutely does not matter for the rotation of the marker.
And use SmoothDamp or Lerp for the animation, instead of SmoothDampAngle.
Kind Regards,
Infinity Code Team.
Boost your productivity a lot and immediately using
Ultimate Editor Enhancer.
Trial and non-commerce versions available.