playMaker

Author Topic: how to change the speed of the object moving on itween path-unity  (Read 2201 times)

Achu

  • Playmaker Newbie
  • *
  • Posts: 1
I have a object called "Cube" and I have dragged the itween.cs code to the camera and have set up the path.Now I need to move the cube on the path,along with that I need to control the speed of the cube while moving on the path.I mean that when the objecting is moving along the path when I press "S" key on my keyborad the object should move slowly ,When I press "F" the object should move fast along the path.I have written the code for it.But the issue Iam facing is when I press "S" the object is moving slowly,but when I press "F" the object is getting back to its starting position where it was and then its starts moving fastly.Each time when the corresponding key is presses the object is moving back to it starting position and then its moving. I tried to solve out the issue but Iam not able to do it.Can anybody please help me out solving the issue.Below is the code I have wirtten and attached to the gameobject


Code: [Select]
void Update () {

if(Input.GetKey(KeyCode.S))
{

iTween.MoveTo(gameObject1,iTween.Hash ("path",iTweenPath.GetPath("train"),"speed",0.1f));
}

if(Input.GetKey(KeyCode.M))
{


iTween.MoveTo(gameObject1,iTween.Hash ("path",iTweenPath.GetPath("train"),"speed",0.5f));
}
if(Input.GetKey(KeyCode.F))
{

iTween.MoveTo(gameObject1,iTween.Hash ("path",iTweenPath.GetPath("train"),"speed",0.2f));
}




pempo

  • Playmaker Newbie
  • *
  • Posts: 13
Re: how to change the speed of the object moving on itween path-unity
« Reply #1 on: May 25, 2022, 05:51:59 AM »
Did you solve the problem?