I have set an itween path for an object to move.And I have written the code as
iTween.MoveTo(gameObject,iTween.Hash ("path",iTweenPath.GetPath("train"),"time",300));
The above code is working for me.
Now I need to apply the change in speed that mean,when i press “S” the object should move Slow,when I press “F” the object should move Fast,When I press “M” the object should move with a medium speed on the itween path.I have written a code for.Below is the code
void Update () {
if(Input.GetKey(KeyCode.S))
{
iTween.MoveTo(gameObject,iTween.Hash ("path",iTweenPath.GetPath("train"),"time",300));
}
if(Input.GetKey(KeyCode.M))
{
iTween.MoveTo(gameObject,iTween.Hash ("path",iTweenPath.GetPath("train"),"time",100));
}
if(Input.GetKey(KeyCode.F))
{
iTween.MoveTo(gameObject,iTween.Hash ("path",iTweenPath.GetPath("train"),"time",50));
}
}
When I runned my above code,and when I press “S” key its moving slowly,next when I press “F” the object is going back to the original position where it was and then it starts moving fast ,same as for the medium “M” also.
I need to change the speed of the object moving on the itween path specified by pressing the keys.Can anybody please help me out.