Author Topic: Is there a way to make the TweenRotation to always take the shortest path?  (Read 2025 times)

Sahkan

  • Jr. Member
  • **
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 74
    • View Profile
When I'm using it, from time to time it will make almost a full circle in order to rotate only 15 degrees.

I only need a fix for when I have an item which has a rotation which is not zero in the z axis and I want it to zero it smoothly.

Edit: I'v noticed it happens only for rotations that will start with a negative value. That means more then 180.
It appears like it will only rotate clock-wise, Is there a way to change it?
« Last Edit: January 21, 2016, 01:57:32 AM by Sahkan »

Sahkan

  • Jr. Member
  • **
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 74
    • View Profile
Ok i'v solved my problem by making a custom tweener that uses NGUIMath.SpringLerp.
It would be awesome if it could be done with the default TweenRotation so I can use the animation graph also.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
TweenRotation has a flag: "quaternionLerp". Quaternions take the shortest path. Mathf.Lerp will take the long path (ie 0 to 360 would be instant with the quaternion lerp, but with Mathf.lerp it's a full 360 degree rotation.