- Home /
iTween: change parameters during the path
Hello People
I'm using the itween moveto function to move a gameobject along a path. Now i want the gameobject to go faster between point 3 and 5. Can i change the speed parameters during the path? Or is there any other way to do this?
Thanks in advance for your help!
Answer by robertbu · Feb 28, 2013 at 11:51 AM
One way is to use PutOnPath() or PointOnPath() to place the game object on the path. The last parameter of these two methods is the percent of the way through the path to place the object/point. To use these, you'll have to write code that increments the percentage at at some rate. You can increase the percentage faster between points 3 and 5. Untested example code. Assume your points 3 and 5 are at .47 and .65 of the way along the path:
float fFraction = 0.0f;
float fFastRatePerSecond = 0.2f;
float fSlowRatePerSecond = 0.1f;
void Update()
{
if (fFraction >= .47 && fFraction <= .65)
fFraction += fFastRatePerSecond * Time.deltaTime;
else
fFraction += fSlowRatePerSecond * Time.deltaTime;
iTween.PutOnPath(myGameObject, path fFraction);
}
Your answer
Follow this Question
Related Questions
iTween MoveTo + Rotation? 2 Answers
Go back to first node (itween + moveto) 2 Answers
iTween, moving to a node on a path. 1 Answer
iTweens MoveTo and "path" property 7 Answers
iTween - look for new path, move to or reverse at end? 0 Answers