- Home /
 
               Question by 
               schetty · Mar 22, 2013 at 09:32 AM · 
                animationitweenitweenpath  
              
 
              iTween Get the path from object nodes and move the object at same speed by loop
Hi, 
 I need to move my camera using the itween function with itween nodes when moving camera should look at the target object. camera rotate at continuous loop and which is move the same speed.
I have try to to this but still i have a issue.
So, please hep me to do this.
Thanks.
               Comment
              
 
               
              I have tried this code but its not working...
 void Start () {
         
         path = iTweenPath.GetPath("$$anonymous$$ain");
     
         move = false;
         percent = 0.0f;
     }
     
     // Update is called once per frame
     void Update () {
         
         
         if(move)
         {
             percent += 0.005f;
             
             if(percent > 4)
                 percent = 0;
         }
         
     
     }
     
     void OnGUI()
     {
         if(GUI.Button(new Rect(0,0,100,30), "Testing"))
         {
             move = true;
             iTween.PutOnPath(gameObject, path, percent);
         }        
             
     }
Answer by dorpeleg · Mar 22, 2013 at 04:39 PM
You don't need the whole percent changing.
Your code should only be:
 void Start () {
  
        path = iTweenPath.GetPath("Main");
 
     }
  
     // Update is called once per frame
     void Update () {
  
     }
  
     void OnGUI()
     {
        if(GUI.Button(new Rect(0,0,100,30), "Testing"))
        {
          iTween.PutOnPath(gameObject, path, percent);
        }     
  
     }
And instead of using PutOnPath, use MoveTo with looktarget and other settings.
look at the documentation: iTween Docs
 iTween.$$anonymous$$oveTo(gameobject, iTween.Hash("path", iTweenPath.GetPath("Path1"), "orienttopath", true, "looktime", 0.001f, "lookahead", 0.001f, "speed", Speed, "easetype", "linear", "looptype", "loop"));
Here is a sample from one of my codes.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                