How to change the speed of the gameobject moving on the itween path

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.

According to the documentation, you can pass a speed argument.

• how to apply the methods through code – user1509674 Mar 16 '15 at 9:04
• iTween.MoveBy(gameObject, iTween.Hash("x", 2, "speed", 0.1)); based on what key you have pressed you can change value of speed. – 2600th Mar 16 '15 at 9:19
• i gave the above code on my keypress but its not working – user1509674 Mar 16 '15 at 9:27
• I couldn't get it working . – user1509674 Mar 17 '15 at 12:17

This will set the speed to 8:

Hashtable props = new Hashtable();