Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to make iTween.PutOnPath restarts the path again and again?

Discussion in 'Scripting' started by Hala, Jul 21, 2013.

  1. Hala

    Hala

    Joined:
    May 13, 2013
    Posts:
    31
    ( I'm new to this)
    I'm working on an endless runner game with 3 lanes, iTween.PutOnPath helps me to make the player follow the path and to switch between lanes, however It doesn't start over the path ( which is something crucial in my game).
    - I've tried using a trigger at the end of the path and once it triggered, call the function again at the first path point but it didn't work
    - I've used iTween.MoveTo , but it doesn't switch between lanes correctly.
    - is there a way where I can make put on path start over the path once it is finished or perhaps a combination of putonpath and moveto?
     
  2. Nethekurse

    Nethekurse

    Joined:
    Oct 29, 2013
    Posts:
    4

    Just use
    Code (csharp):
    1.  iTween.PutOnPath(gameObject, path, PathPercent);
    PathPercent = 0.0f for begin and 1f for end. Use
    Code (csharp):
    1. PathPercent += 0.01f  * Time.DeltaTime;
    You can make a simple loop doing this:

    Code (csharp):
    1. if(PathPercent >= 1)
    2. {
    3.   PathPercent = 0;
    4. }
    You can find more information on this topic: http://answers.unity3d.com/questions/408334/itween-path-swap.html