- Home /
Problem with iTween and instantiated path
Hi everyone! I have just started to use iTween (don't know much about it). I am making an endless runner for which I instantiate my prefab with iTweenPath script attached to it(from the iTween Visual Editor). The problem is when I instantiate the prefab(with which I have a iTween path attached, namely p2), the function iTweenPath.GetPath("p2") throws an error that it cant find the path "p2" (but I just instantiated it, and the name hasn't changed at all). Am I doing something wrong? Please help.
void Start () {
CurrPref = Instantiate (pref1, new Vector3 (15, 0, 0), Quaternion.identity) as GameObject;
CurrPref.name = "p2";
CurrPref.GetComponent<iTweenPath> ().nodes.Clear ();
CurrPref.GetComponent<iTweenPath> ().nodes.Add (new Vector3 (CurrPref.transform.position.x - 5,0,0));
CurrPref.GetComponent<iTweenPath> ().nodes.Add (new Vector3 (CurrPref.transform.position.x + 5,0,0));
CurrPref.GetComponent<iTweenPath> ().pathName = "p2";
iTween.MoveTo (gameObject,iTween.Hash("path",iTweenPath.GetPath("p1")
,"time",1
,"easetype",iTween.EaseType.linear
,"OnComplete","MoveNext"
,"OnCompleteTarget", gameObject));
}
void MoveNext () {
iTween.MoveTo (gameObject, iTween.Hash ("path", iTweenPath.GetPath("p2")
, "time", 1
, "easetype", iTween.EaseType.linear));
}
( @robertbu , please help! :p )
Comment