- Home /
How does Paths Works on iTween
Hello guys, I'm starting with iTween and I want to do a Path Follow, to make that I need to create some empty Gameobjects and rename them ? Like (1,2,3,4,5) And say to iTween to do the path ?
I saw a script but I dont undertood the Hash
iTween.MoveTo(gameObject, iTween.Hash("path", new Vector3[]{new Vector3(1,2,3), new Vector3(2,1,3), new Vector3(3,2,1)}, "time",5));
And
iTween.MoveTo(gameObject, iTween.Hash("path",iTweenPath.GetPath("Path1"), "time",5));
I need some "light" to start to do.
Thanks Guys
i tried to use this by creating a path in a string which is made from arrays and loops to create the path.
code is iTween.$$anonymous$$oveTo(gameObject, iTween.Hash("path", tempPath, "time",5));
sample string would be tempPath = "new Vector3[]{new Vector3(-33.7, 0.8, -32.9), new Vector3(-33.7, 0.8, -27.2), new Vector3(-33.7, 0.8, -21.5), new Vector3(-33.7, 0.8, -15.4), new Vector3(-33.7, 0.8, -9.0), new Vector3(-33.7, 0.8, -3.6), new Vector3(-33.7, 0.8, 2.9), new Vector3(-33.7, 0.8, 9.3)}"
but I get the error
InvalidCastException: Cannot cast from source type to destination type. iTween.Generate$$anonymous$$oveToPathTargets () (at Assets/Plugins/iTween.cs:3523) iTween.GenerateTargets () (at Assets/Plugins/iTween.cs:3162) iTween.TweenStart () (at Assets/Plugins/iTween.cs:4603) iTween+c__Iterator2.$$anonymous$$oveNext () (at Assets/Plugins/iTween.cs:6567)
any suggestions?
Answer by ByteSheep · May 10, 2013 at 06:20 PM
The first code snippet is creating three Vector3s and storing them in a Vector3 array.
The second piece of code retrieves an iTweenPath named "Path1" and uses the points created for that path.
One of the useful features of iTween is the visual path editor that lets you easily create these paths - here's an example:
http://www.youtube.com/watch?v=qRafXt26a_E
The only way is using iTween Visual Path ? I foud only iTween Visual Editor on asset store, this is the only way ?
No, as shown in the first code snippet you can create an array of 3d points directly in the code that form a path.
The array of Vector3 points is this part:
new Vector3[]{new Vector3(1,2,3), new Vector3(2,1,3), new Vector3(3,2,1)}
The first bit declares the array and would be:
new Vector3[]{}
Then you can start adding Vector3 points inside the array:
new Vector3[]{new Vector3(0,0,0), new Vector3(0,0,5)}
If you don't know what a Vector3 is then you can check the docs here.
I solved from another way, without visual editor, thanks guys =)
Your answer
Follow this Question
Related Questions
Push an object along a path? 2 Answers
itween path restrict rotation on TWO axis 0 Answers
Camera switching with iTween Touch 1 Answer
iTween Path easing in and out 0 Answers
iTween Path Rotation 0 Answers