Search Unity

Help with Quaternion.Slerp

Discussion in 'Scripting' started by gilson, Mar 21, 2011.

  1. gilson


    Sep 13, 2010
    Im using Quaternion.Slerp to do some specific rotations but i have some problems, because the method assumes the shortest path to rotate towards the desired angle.

    I want to know if theres a way that i can tell the Quaternion.Slerp function to rotate to that angle clockwise or counter-clockwise. Is it possible?

    Thank you
  2. Jesse Anders

    Jesse Anders

    Apr 5, 2008
    Quaternion SLERP functions are typically implemented so that the interpolation takes place over the shortest arc.

    From your mention of clockwise and counterclockwise though, it sounds like maybe it's essentially a 2-d problem you're trying to solve. If so, you should be able to achieve what you're wanting by manipulating the object's rotation angles directly, or rotating the object directly using e.g. Transform.Rotate().

    If that doesn't seem like a suitable solution, perhaps you could clarify what it is you're trying to do exactly.