- Home /
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.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Kongregate API not connecting C# 2 Answers
How to store player model and then swap the model to an object I Raycast hit? 0 Answers
How to solve AR Model of 250 MBs size from hanging or lagging while running in mobile camera? 0 Answers