I am trying to use iTween to follow a looping path I created and have my sprite orient to the path on the z-axis so it rotates as it follows the path. I am using 2D Toolkit sprites.
The problem is that it doesn’t seem to be working. And if I don’t restrict the Z-axis, the sprite becomes invisible because of x/y rotation happening. Not sure what I am doing wrong.
Relevant Code Snippets:
if (Input.GetKeyUp(KeyCode.L) && !bCharFollowingPath)
{
bCharFollowingPath = true;
ht = new Hashtable();
ht.Add("path", iTweenPath.GetPath("Loop1"));
ht.Add("time", 4f);
//ht.Add("looktime", 0.6f);
ht.Add("lookahead", 0.1f);
ht.Add("orienttopath", true);
ht.Add("axis", "z");
ht.Add("easetype", iTween.EaseType.linear);
ht.Add("oncomplete", "Path_OnComplete");
ht.Add("oncompletetarget", this.gameObject);
iTween.MoveTo(sprChar.gameObject, ht);
}
}
void Path_OnComplete()
{
Debug.Log("Done");
bCharFollowingPath = false;
sprChar.transform.position = new Vector3(150, -316, -5);
sprChar.transform.eulerAngles = new Vector3(0, 0, 0);
}
z-restricted:
not z-restricted:
It does appear by looking at the wireframe on the not-z restricted, that it is following the path and rotating but not in a way that is useful =)
Any help greatly appreciated.