- Home /
itween path in javascript
Hello! i have to move an object along an itween path. I need to code this inside a javascript script (the action will be performed when a GUI.Button is pressed). I don't know how to code this in javascript, there are only c# examples. Can you help me?
Have you read the iTween "Getting Started" page? It does explain some basics there. http://itween.pixelplacement.com/gettingstarted.php
Do you need help making a Javascript hashtable to tell iTween what to do?
Answer by Screenhog · Sep 12, 2012 at 04:34 PM
You'll need iTween.MoveTo, and it will look something like this:
var myPath = Transform[];
function OnGUI () {
if (GUI.Button(Rect(10,10,100,50), "Click me!")) {
iTween.MoveTo(gameObject,{"x":3,"time":4,"path":myPath});
}
}
The first line (var myPath = Transform[]) is the list of objects that MoveTo will use to go along the path. You'll need to define those yourself in the Inspector.
Thanks, it worked! but i had to copy all the nodes position values into a new Vector3 array..
Your answer
Follow this Question
Related Questions
How to move an object on a random path with iTween 1 Answer
[SCREENSHOTS] itween Path, orientToPath and gameObject rotation, 2D game 3 Answers
itween MoveTo IndexOutOfRangeException 0 Answers
Accessing Vector3s of GameObjects in Arrays (JS) 1 Answer
How to create homing missile that follows path using Unity and iTween 1 Answer