Search Unity

iTween animation system

Discussion in 'Assets and Asset Store' started by pixelplacement1, Apr 13, 2010.

  1. fmarkus

    fmarkus

    Joined:
    May 22, 2010
    Posts:
    181
    Fantastic! Thanks for the hard work!
    Just wondering, are all functions possible now on the update loop, or the ones with 'update' in the name?
    Cheers!
     
  2. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    My best advice would be: just try it out. But yes, all of them (that make sense) can be used in the Update function. But just remember that the "update" versions are more efficient.

    Let me know if you have any problems and if anything needs an example on the support page.
     
  3. pegorari

    pegorari

    Joined:
    Nov 19, 2009
    Posts:
    60
    Hello

    I was trying to use the bezier path animation into my project, but I saw the animation starts from the object (the object initial position change the spline shape). Would be nice if in next itween update we can choose start the animation from the first spline point.

    Thanks, Itween is great!
     
  4. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Fair enough. I'll put a Boolean in that can be set to decide if the path is automatically built from the object's location or not. Thoughts on what to call it?
     
  5. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    How does "moveToPath" sound for this?
     
  6. pegorari

    pegorari

    Joined:
    Nov 19, 2009
    Posts:
    60
    I like "moveToPath", quite simple!

    Thanks man, will be a great help. In some weeks I show you my game running. At this point, it´s 80% using itween for animations :wink:
     
  7. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Perfect, I'll add it when I get time. Look forward to seeing your game!
     
  8. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    2.0.08 now has the "movetopath" toggle as you requested. I also "tweaked" the way DrawPath() works; I removed the way it automatically creates a path segment from the object's current position to the start of the path. It just works better this way.
     
  9. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    I forgot to let you know that the new iTween isnt working for me at all. Im trying the new MoveBy command and Im getting errors.

    "Unknown identifier: 'MoveBy'."

    I have no idea what the problem is at all but I'm sure im doing something wrong... :-/

    Code (csharp):
    1. MoveBy(GameObject, -0.2, .1);
     
  10. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    You need to make a call to iTween in your function call, also MoveBy would need a GameObject reference not the type as well as a Vector3 (or you could use the other version that takes a Hashtable just like version 1 does.

    The code you posted should be:
    Code (csharp):
    1. iTween.MoveBy(gameObject, Vector3(-0.2,0,0), .1);
    Please consult the getting started page: http://itween.pixelplacement.com/gettingstarted.php
     
  11. pegorari

    pegorari

    Joined:
    Nov 19, 2009
    Posts:
    60

    I tried here, it´s working sweet! Now I´m starting to change a lot of code for this sigle call in my game. Thanks again for this great tool!
     
  12. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
  13. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Hmm...i thought i read somewhere that i you changed it to write the code like that...must of misunderstood, lol.

    Thanks.

    EDIT:err, now im getting this:
    Code (csharp):
    1.  
    2. Unknown identifier: 'iTween'.
     
  14. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Post an image of your assets folder.
     
  15. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
  16. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Take a second look at the "Getting Started" page since you are trying to use iTween from JavaScript. It needs to be in a "Plugins" folder.
     
  17. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Whoops! A failure is me. That's where i put the last iTween so I thought it went there again. *smacks head*

    Thanks!
     
  18. pegorari

    pegorari

    Joined:
    Nov 19, 2009
    Posts:
    60
    Hello Again!

    I have another doubt, is about the way that the first waypoint is oriented to (0,0,0) of the scene.

    I made a small test to show you: A gameObject with a script, and 3 gameobjects as child. I moved the group to left and right, then the spline was deformed. I don´t know, but I think Itween is reading the (0,0,0) of scene like the first spline point...



    Here is the script that I´m using on parent gameobject to auto-calculate child objects as spline points

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class teste_path : MonoBehaviour
    6. {
    7.  
    8.     public bool ShowGizmos = false;
    9.     private Vector3[] pathCalculado;
    10.     public Vector3[] path;
    11.    
    12.     void OnDrawGizmos()
    13.     {
    14.         Gizmos.color = Color.green;
    15.         //se possui waypoints...
    16.         if (transform.GetChildCount() > 0)
    17.         {
    18.             pathCalculado = new Vector3[transform.GetChildCount()];
    19.             for (int cc = 0; cc < transform.GetChildCount(); cc++)
    20.             {
    21.                 if (ShowGizmos) Gizmos.DrawWireSphere(transform.GetChild(cc).transform.position, 0.3f);
    22.                 pathCalculado[cc] = transform.GetChild(cc).transform.position;  
    23.             }
    24.             path = pathCalculado;
    25.             if (ShowGizmos) iTween.DrawPath(GameObject.FindGameObjectWithTag("Player"), path);
    26.         }  
    27.  
    28.     }
    29.  
    30. }
    31.  
    32.  
     
  19. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Are all three in an exact straight line? I assume this sort of setup will cause issues with the Catmull-Rom calculation. If you need a straight line just use MoveTo()
     
  20. pegorari

    pegorari

    Joined:
    Nov 19, 2009
    Posts:
    60
    Yes, in this case the 3 points are in line, just to show you!

    Im my puzzle game I´m using Itween to make a ball slide in line movements, and another path script to make the ball roll in loops. Would be nice to see all movements running just with Itween, but is awesome this way, tnx again!
     

    Attached Files:

  21. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Cool. Do you need me to look into this as an issue or are you good? Your game looks awesome so far!
     
  22. pegorari

    pegorari

    Joined:
    Nov 19, 2009
    Posts:
    60
    It´s all ok! This will be nice for future Itween updates!!!! I´m Glad you like it, as soon I show you :wink:
     
  23. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Awesome, look forward to it. So, basically I need to make a solution that creates a linear line if all points are in a straight line. Right?
     
  24. pegorari

    pegorari

    Joined:
    Nov 19, 2009
    Posts:
    60
    I think this should be a better way, there is no helper brackets working together and is like all vector softwares work
     
  25. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    You lost me... sorry.
     
  26. pegorari

    pegorari

    Joined:
    Nov 19, 2009
    Posts:
    60
    Don´t worry, it´s all great this way.
    (And I know, my English is very bad! :oops:)
     
  27. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    hey pixel, i dont know, but im still seeing drops in framerate when using iTween compared to transform.translate...and I'm not sure why since you said it will work inside an update...
     
  28. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    I appreciate the support! I still want to see your game when it's ready!
     
  29. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Have you tried using the "Update" version of the method you are trying to use?
     
  30. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Are you talking about moveUpdate?
     
  31. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Sure, as the docs state the "Update" versions of the methods are less expensive. So if the regular versions are too expensive you can use them.

    Cool?
     
  32. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    lol, thats not what I want at all. I did:
    Code (csharp):
    1.  
    2. iTween.MoveUpdate(gameObject, Vector3(0, 0, 0.2), .7);
    and it just moves me to that coordinate lol...

    i want it to move in that direction. Here is the origin code...
    Code (csharp):
    1.  
    2. if (controller.animType == 1){
    3.            
    4.             iTween.MoveBy(gameObject, Vector3(0,0,0.1), .7);
    5.             animation.Play ("att1");
    6.                
    7.                        
    8.         }else if (controller.animType == 2){
    9.             animation.Stop("att1");
    10.             iTween.MoveBy(gameObject, Vector3(0,0,0.2), .7);
    11.             animation.Play ("att2");
    12.                
    13.            
    14.         }else if (controller.animType == 3){
    15.             animation.Stop("att2");
    16.            
    17.             iTween.MoveBy(gameObject, Vector3(0,0,0.1), 1);
    18.             animation.Play ("att3");
    19.         }else if (controller.animType == 4){
    20.             animation.CrossFade ("absorb");
    21.  
    22.         }
     
  33. tof42

    tof42

    Joined:
    Feb 3, 2009
    Posts:
    6
    Hey !

    I am trying to use iTween to make a 2D sprite (managed by Sprite Manager 2) to go white in 2 seconds.
    So I am using this line of code :

    iTween.ColorTo(go,iTween.Hash("color",new Color(255f,255f,255f),"easetype", "linear", "oncomplete","onRelease","time",2));

    And the sprite goes white but instantly, not progressively over the 2 seconds period.

    Any idea ? Am I missing something ?

    Btw, iTween is really an awesome project !!!
     
  34. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Thanks for the support!

    I've never used Sprite Manager so I can't speak for what's going on in the background but your statement is correct. You can shorten the call some because Color methods in iTween default to an "easetype" of "linear" but I'm not sure what Sprite Manager could be doing to stop iTween from interpolating. If you figure this out can you please share?
     
  35. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Interesting. There's a few ways to solve this.

    First you could set a boolean named something like "isAnimating". Next add a check to each of those if-statements that also makes sure "isAnimating" is false. Now whenever one of your if-statements resolves to true you can fire the iTween and call an "onstart" callback that sets "isAnimating" to true as well as add an "oncomplete" that will set "isAnimating" back to false as well as change the "controller.animType" to something that will cause the if-statements to not fire continuously.

    If this solution isn't what you need you should probably just rely on Unity's Transform.Translate() method as iTween is truly built more for presentational and animation aspects of game design and may not be your best solution for this situation.

    Always remember.... use the right tool for the job.
     
  36. Twidusk Studios

    Twidusk Studios

    Joined:
    Aug 13, 2010
    Posts:
    42
  37. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    There's a new example on the support page showing how to use waypoints and speed rather than time with MoveTo. Let me know if this helps solve the issue you were having with MoveTo and the "path" property causing curves when you didn't want them: http://itween.pixelplacement.com/examples.php
     
  38. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Not quite sure I understand the solution completely. I actually made the iTween be in a function besides update and just called it. Didnt really make much of a difference. I really dont like the transform.Translate since its not giving me the smooth movement I want like what iTween does, I dunno. :/
     
  39. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Sorry you are still confused; I hope you can figure out a solution!
     
  40. pegorari

    pegorari

    Joined:
    Nov 19, 2009
    Posts:
    60
    Hello Pixel, I saw the demo, I´m using a similar way to move between waypoints in straight lines (In my case I placed a Trigger component in a Waypoint, so when there is a collision, the object go automatically to another pre-set waypoint position).

    At this time I´m using another Spline system that i´ve found in the forum. It´s running fine, but should be nice replace this scripts for just Itween. I´m using where there is a loop/curve in middle of this path. The problem that i´ve found using Itween was this transition, from a straight line to a spline, because the first spline point starts affected by the (0,0,0), that don´t allow a smooth transition from the MoveTo and the Spline.

    I liked the way that Itween makes an automatic waypoint from the GameObject, it´s very usefull for a lot of purposes. But when I tried to turn off the "movetopath", the first spline point, instead of the GameObject, goes to (0,0,0). I think that should be more usefull, in this case, if the first spline point is the self first spline point position!

    P.S.: (The new function ValueTo is very usefull man!!! Replacing now my GUI animations with this...)
     
  41. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    I hear you. The only reason why I need to add that extra control point is because I'm using Catmull-Rom splines and then need a control point before and after the path in order to calculate the "in" and "out".

    I'm glad you are able to figure something out and I'm looking forward to seeing the outcome!
     
  42. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
  43. outtoplay

    outtoplay

    Joined:
    Apr 29, 2009
    Posts:
    741
    These are terrific. Will indeed purchase in the near future. I really appreciate your work on iTween, and have no doubt many here in the community do as well.

    Great stuff,
    B.
     
  44. galent

    galent

    Joined:
    Jan 7, 2008
    Posts:
    1,078
    Hi,

    First thank you very much for iTween! That's some nice work! :)

    I do have a question, I'm encountering a strange anomoly in MoveTo. I'm generating a set of random path points between two fixed game objects, but when I generate the random path, as opposed to pre-creating path points, MoveTo seems to inject a first step into the path that is way out of line with the other points. I've steped through all the generated objects/points after start, and they're all in line, in fact I can't find any transform at the position indicated by the moveTo.

    I did the drawPath and verified that it does seem to think there's a point out there in space. Now, it also throws an error in editor mode (as the path points aren't generated until the script Start() method is complete at runtime.

    Any ideas what's happening there?

    Thanks,

    Galen
     
  45. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Any chance you can get me an example project so I can look into this for ya?
     
  46. galent

    galent

    Joined:
    Jan 7, 2008
    Posts:
    1,078
    Here's a screen shot of the paths, the white path was generated by iTween during DrawPath(), the Blue is the path the object took under MoveTo() control.

    Cheers,

    Galen
     

    Attached Files:

  47. galent

    galent

    Joined:
    Jan 7, 2008
    Posts:
    1,078
    Sure, PM me and let me know where you want it sent :)

    Cheers,

    Galen
     
  48. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    This should now be fixed as of v2.0.14. Let me know!
     
  49. galent

    galent

    Joined:
    Jan 7, 2008
    Posts:
    1,078
    Yup,

    that fixed it!

    Thanks,

    Galen
     
  50. jhem00

    jhem00

    Joined:
    Jul 16, 2010
    Posts:
    29
    just wanna know what happened to MoveToBezier? is it renamed? thx!