iTween orienttopath

I want a GameObject to go in orbit and rotate along with the path.

The orienttopath portion of iTween seems to rotate in all strange directions, I mean in addition to rotating along the path, it seems to twist also! What are the details on how this rotation is performed, the docs doesn’t contain enough info?

Example: In my case I’m working in 2D (xy-plane), so when my GO (or in my case a sprite) is rotating along with the path, I don’t want it to rotate allong certain axis.

Further debug and “research” leads me to believe that iTween is using something like this:

void Update() {
  transform.LookAt(transform.position + [a point ahead of direction]);
}

According to the docs on LookAt it will point the forward axis (z) to the target and its up (y) to the worldUp vector unless one state a second argument. Now the strange behavior happens because the local y-axis will never actually align with worldUp, since the local forward (z) is the main master of rotation, so sometimes when the y-axis comes close to the worldUp (or worldY) it will flip. This is easier to see than describe I now realise :slight_smile:

Anyway, my solution is to turn off orienttopath and do it manually instead, with a custom second argument to LookAt like this:

void Update() {
  transform.LookAt(transform.position + [a point ahead of direction], -Vector3.forward);
}

If you are trying to use iTween’s “orientToPath” in a 2D scenario why not just include the “axis” property to limit the look to only one axis? If you still need to roll your own look solution iTween’s PutOnPath will help out with this. I’m using this approach in the PutOnPath example: http://itween.pixelplacement.com/examples.php#putonpath