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

iTween animation system

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

  1. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
  2. Slem

    Slem

    Joined:
    Jan 28, 2009
    Posts:
    191
    Im having trouble getting the "oncomplete" event to fire when using ValueTo. It crashes Unity.

    Code (csharp):
    1.  
    2. //This does work
    3. public void Show(float time, float delay)
    4.     {
    5.         iTween.ValueTo(gameObject, iTween.Hash("time", time, "delay", delay, "from", CurrentRect, "to", ViewportToScreenRect(ShowRect), "onupdate", "MoveRect" ,"easetype", EaseType.ToString().ToLower()));
    6.         _Visible = true;
    7.         OnShowStartedEvent(this);
    8.         //Invoke("TweenComplete", time + delay);
    9.     }
    10. //This crashes everytime
    11. public void Show(float time, float delay)
    12.     {
    13.         iTween.ValueTo(gameObject, iTween.Hash("time", time, "delay", delay, "from", CurrentRect, "to", ViewportToScreenRect(ShowRect), "onupdate", "MoveRect", "oncomplete", "ShowComplete", "easetype", EaseType.ToString().ToLower()));
    14.         _Visible = true;
    15.         OnShowStartedEvent(this);
    16.         //Invoke("TweenComplete", time + delay);
    17.     }
    18.  
    19. public void ShowComplete()
    20. {
    21.     OnShowEndedEvent(this);
    22. }
    23.  
    Am I using it wrong? Do I need to add a parameter to the oncomplete (here: ShowComplete) method?

    Btw. Thanks for this. Very good work.
     
  3. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    does anyone know how Infinite Ammo got around the Time.timeScale zero issue without troubles?

    P.S., wow, iTween is such a cool tool, I'll try to buy all your example projects just to support your development of this great unity addition, thanks PixelPlacement!!!
     
  4. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    iTween can now be set to operate independent of the current timeScale in a project! If you add a parameter of "ignoretimescale" that is set to true you can easily animate with iTween after you have adjusted Time.timeScale.

    Biggest benefit? Pause menus that you can still animate after setting Time.timeScale=0 to pause your game.
     
  5. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    awesome new addition PixelPlacement! I've been yearning to see timescale independent usage in iTween for a while now.
     
  6. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    I don't have either so I can't say how to implement iTween with them. I guess I need to break down and purchase/learn them. Anyone out there have experience with using iTween with these?
     
  7. beezir

    beezir

    Joined:
    Apr 3, 2009
    Posts:
    133
    I'm using EZ GUI with iTween on Android and it works just fine. That said, I'm not doing anything massively complicated. I use EZ GUI's transitions for the simple stuff, and iTween for any real animation.
     
  8. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    I've tried SM2 with iTween (when I was working on some path drawing stuff) and didn't see any problems, however I was just prototyping so my use cases were pretty simple.

    On a related note I made some slight additions to enable the path stuff in iTween to work with GUITextures via pixelInset instead of transforms (effectively just rounding and a few other simple changes) these might be a useful addition for some...
     
  9. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Email me so we can see about adding it to iTween :)
     
  10. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    NICE!!! SM2 EZGui integration = AWESOME, my 3 favorite Unity stalwarts
     
  11. AssH

    AssH

    Joined:
    Oct 20, 2010
    Posts:
    5
    Hi Pixelplacement ;)

    I'm new with Unity and I wanted to thanks for your work, it's really usefull for us !

    But, I've the same problem... "Unknown identifier: 'iTween'."
    I don't know why, I follow your "getting starter", but always the same error...

    Here is my folder screenshot, Can you help me ?


    Thanks !

    ./
     
  12. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Can you provide the full error message?
     
  13. diabloroxx

    diabloroxx

    Joined:
    Jan 20, 2010
    Posts:
    71
    I just checked the Sliding Menu example. Is it possible to have multiple GUI buttons and have multiple images attached to them and have them slide one after another, like a scroller bar or something similar.
     
  14. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Not something specific to iTween, but can you maybe provide some visuals and I'll help out.
     
  15. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    does anyone have an documentation on the new features (the vector update additions) that Bob just added?
     
  16. diabloroxx

    diabloroxx

    Joined:
    Jan 20, 2010
    Posts:
    71

    I am trying to make GUI Buttons very very similar to this : http://valums.com/files/2009/menu/final.htm
     
  17. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,123
    I am trying to make something fade from being invisible to back to visible... in 5 seconds.. problem is for the most part if i put time on 5 it happens instnatly...
    The following works great.. only takes 1 second and it disappears... problem is whats after

    iTween.FadeTo(buttonFreezer,iTween.Hash("alpha",255, "amount", 0, "delay",1,"time", 1,"easetype", iTween.EaseType.easeInOutSine, "onComplete", "Deactivate", "onCompleteParams", buttonFreezer, "onCompleteTarget", thisObject ));


    The problem is this... when i try to make it refade.. it doesnt seem to use the time by the number of seconds... it just makes it happen super fast so i gotta increase it to like 30, which i didnt mind.. but now thats not even working for certain instances... What is happening? And how do i make an object come back from being invisible properly. In say... taking 5 seconds to become fully visible.

    buttonOutside.active = true;
    iTween.FadeTo(buttonOutside,iTween.Hash("alpha",255,"time", 30,"easetype", iTween.EaseType.easeInOutSine));
     
    Last edited: Nov 21, 2010
  18. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    @zhx
    @Kurylo3d

    I'll try to get you guys answers very soon. Sorry, just been a little busy. Hang tight!
     
  19. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    @pixelplacement
    you rock!!!! Thanks for sharing your time with the world(via iTween). I was happy to be able to have purchased the entire series of example scenes from your site. Cant wait for the new vertex animation script you're working on(assuming you support "shapekeys" from blender, AKA "blendshapes" from maya, as I no longer use Maya). I'd happily pay you for your time(via unity assets, or donation, etc).
     
  20. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Thanks! I'm right in the middle of a few things but my blendshape tool is still very on my radar. I only use Maya but when it comes time maybe I'll bug you so you can help me also support shapekeys (shouldn't be dificult).

    As far as the newest methods I added to iTween (Vector3Update, FloatUpdate and Vector2Update), they are simply easy ways to set up real-time easing solutions. Here's how to create a very simple, eased mouse follower with one of them (Vector2Update):

    Code (csharp):
    1. Vector2 mouseFollowerPosition;
    2.    
    3. void OnGUI(){      
    4.      GUI.Label(new Rect(mouseFollowerPosition.x,mouseFollowerPosition.y,95,20), "Mouse Follower");
    5.      mouseFollowerPosition = iTween.Vector2Update(mouseFollowerPosition, Event.current.mousePosition, 4);
    6. }
     
  21. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    I'm not sure what you are doing with the "alpha" value you have in both of those iTween calls but all you need is the "amount" OR "alpha" with the Fade methods. Also, I wouldn't recommend an "easetype" with color animations such as Fade as it's extra computation for something that's virtually undetectable by the human eye and iTween defaults to "linear" with any of its animations that compute color as a result (unless you override it as you are).

    This should work for you as a simple base to fade something out and then back in:

    Code (csharp):
    1.  
    2. iTween.FadeTo(buttonFreezer, iTween.Hash("amount",0,"time",1,"delay",1));
    3. iTween.FadeTo(buttonFreezer, iTween.Hash("amount",1,"time",1,"delay",3));
    Good luck.
     
  22. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Something to get you started on solving this:

    Use GUI.Toolbar to build the series of images with a Rect that uses a variable for the X position
    Use iTween's UpdateFloat to set the position of your toolbar as the inverse of the percentage that the mouse is by querying the Event.current.mouseposition (i.e. Event.current.mouseposition/Screen.width)

    Hope that helps you get started.
     
  23. diabloroxx

    diabloroxx

    Joined:
    Jan 20, 2010
    Posts:
    71
    Thanks for the pointer. Will try and implement this first thing tomorrow morning.
     
  24. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Good luck!
     
  25. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,123
    Big thanks for the help! I will try this stuff for the fading in and out as soon as I get home. Also i have been reading your posts and very glad to hear that you are working on blend shapes. I can't wait for this especially since I am also a Maya user.
     
  26. diabloroxx

    diabloroxx

    Joined:
    Jan 20, 2010
    Posts:
    71
    Thanks, that worked with some glitches. Since I am now updating the X value of Toolbar's rect to my mouse position, it runs smoothly. However, the first button always ends up coming under the mouse. I think I may have to split the buttons up individually and then try the same thing.
     
    Last edited: Nov 23, 2010
  27. CrazyIwan

    CrazyIwan

    Joined:
    May 16, 2010
    Posts:
    21
    Hi,

    i have the same problem like Kurylo3d with FadeTo/FadeFrom. First Fade to 0 works very well, but if i want to fade it back to 100 i have to increase the "time" from 3 seconds to 30 and more. Otherwise the animation is done in millisecond. Are you sure there is no bug in FadeTo/From?
     
    Last edited: Nov 30, 2010
  28. kwabbott

    kwabbott

    Joined:
    Jun 5, 2007
    Posts:
    151
    Hi,

    I'm using iTween to do a counter like the ValueTo Example. It works fine, but when I press stop in the editor it attaches a persistent iTween script to the object. After several play/stop cycles I have multiple iTween scripts attached to the gameobject and it stops working correctly.

    The only portion of iTween code is

    Code (csharp):
    1. function CalcTokens (){
    2.     iTween.ValueTo(gameObject,{"from":currentTokens,"to":currentTokens+tokensEarned,"time":(.1*tokensEarned),"onUpdate":"PassTheScore"});
    3.     currentTokens+=tokensEarned;
    4. }
    Any ideas what would cause this issue?

    thanks

    Kevin
     
  29. CrazyIwan

    CrazyIwan

    Joined:
    May 16, 2010
    Posts:
    21
    Hmm, no one any ideas? pixelplacement1?
     
  30. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    No clue... could you get me a sample file so I can take a look?
     
  31. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    That's really odd. Is this still happening? Have you tried a clean Unity project? Let me know.
     
  32. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
  33. malyna

    malyna

    Joined:
    Jul 9, 2010
    Posts:
    105
    Hot stuff !
     
  34. mmuller

    mmuller

    Joined:
    Nov 23, 2010
    Posts:
    92
    love the path editor! how to thank you pixel??? and I love Hooper - he looks so cool!
     
  35. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    All I ask is that you spread the word about it and iTween.
     
  36. Toad

    Toad

    Joined:
    Aug 14, 2010
    Posts:
    298
    iTween is absolutely fantastic! Thanks for everything you've done with this!

    Just seen your path editor and the doc search tool on your blog so downloading them now too.

    Thanks again!!
     
  37. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    is there an easy way to make an itween ScaleTo event loop(via PingPong) only ONCE? I've had to resort to one ScaleTo that makes the object larger(by the amount I am scaling, "2.0" for example).

    THEN I'm using an oncomplete call in the initial iTween ScaleTo event to run another iTween event that reverses the effect of the ScaleTo.

    Its not VERY bothersome, but would be great to be able to NATIVELY make an iTween even perform only 1 loop(or a set amount of loops better yet).

    any insight would be much appreciated.

    Thanks to Bob for EVERYTHING, iTween is beyond useful for my pipelines.(really looking forward to the vertex animation script you're working on! fingers crossed for ShapeKeys support(for blender)).
     
    Last edited: Dec 6, 2010
  38. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Why not just use two iTweens at the same time? One that scales it up with no delay and another that delays for the length of the first and scales it back?
     
  39. kwabbott

    kwabbott

    Joined:
    Jun 5, 2007
    Posts:
    151
    i'm getting the error "unknown identifier: iTweenPath"

    My JS code look like this:


    Code (csharp):
    1. iTween.MoveTo(gameObject,{"path":iTweenPath.GetPath("TourPath"), "speed":4});  

    Is the syntax different for JS?

    thanks for a great tool

    Kevin
     
  40. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Just as with iTween, since it's a C# script and you are using JS just plop iTweenPath into your "Plugins" folder and you should be good. Let me know if this doesn't work for you.
     
  41. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    genius !!
    Thanks Bob


    EDIT:
    is it possible to stop just one iTween, and not all iTweens at once?(assuming I have more than one playing at the time).
     
    Last edited: Dec 7, 2010
  42. wonderlabsstudio

    wonderlabsstudio

    Joined:
    Dec 1, 2010
    Posts:
    21
    Some one may already answered this question, but anyway. After I upgrade from Unity2.6 to Unity3 my iTween acting bit wired.
    My old animation was scale and move action at same time for one second, Code show below:
    Code (csharp):
    1.     iTween.MoveTo(gameObject, moviePos.transform.position,1.0);
    2.     iTween.ScaleTo(gameObject, moviePos.transform.localScale,1.0);
    But after upgrade to Unity3 above code only can animate one action, either MoveTo or ScaleTo, then if I put a WaitForSecond(1) statement in between it working but act like you have delay in between which not the effect I want.

    Any idea that to combine MoveTo ScaleTo same time for iTween in Unity3?

    Best
     
  43. kwabbott

    kwabbott

    Joined:
    Jun 5, 2007
    Posts:
    151
    I did get iTweenPath working in JS - thanks!

    Two things...
    1. I'd like to be able to move a camera to the first point of an iTweenPath before it starts moving along the path. Can I access that point info via code?

    2. I cannot get looktarget to work on the camera from the question above. It gets the correct X rotation but will not the correct Y rotation. I.e., it's looking to the side of the target. Any thoughts?

    thanks again

    Kevin
     
  44. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    I just tested both iTweens and they run at the same time fine for me in Unity3. Not sure what to tell you on this.
     
  45. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Take a look at all of the possible versions of the Stop methods I included. You can't specify a specific iTween but hopefully you can get something working with the available versions.
     
  46. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    iTween path simply returns an array. You could easily grab the first entry to do what you are asking but iTween by default will move your object to the first point of a supplied path for you unless "moveToPath" is set to false.

    Are you using a plain camera? I've used "looktarget" 100s of times and with a regular old "main camera" it works perfectly.
     
  47. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    iTween path simply returns an array. You could easily grab the first entry to do what you are asking but iTween by default will move your object to the first point of a supplied path for you unless "moveToPath" is set to false.

    Are you using a plain camera? I've used "looktarget" 100s of times and with a regular old "main camera" it works perfectly.
     
  48. wonderlabsstudio

    wonderlabsstudio

    Joined:
    Dec 1, 2010
    Posts:
    21
    This is weird, I test the code on my Mac and runs fine too. only got problem on my PC with Win7
     
  49. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    @PixelPlacement

    Are there plans to add in the ability to directly stop and/or reset an individual iTween specifically? Perhaps using events/listeners/etc?

    Stopping all iTweens is useful often(for me), but the ability to directly call to the iTween itself would be my #1 needed feature for iTween(say an instantiation on the stack or something along those lines).

    Aside from that 1 request, I must say that I'm happy to have already purchased ALL of your examples, and continue to support your diligent efforts to innovate and share your findings/creations with the community, thank you!

    EDIT: also wondering if the new visual path creation addition to iTween can be used with the PutOnPath call?
     
    Last edited: Dec 9, 2010
  50. wonderlabsstudio

    wonderlabsstudio

    Joined:
    Dec 1, 2010
    Posts:
    21
    I found where the problem is, it's my gameobject has rigidbody attach to it. In unity2.6 it works fine, but in Unity3. if a rigidbody attach to the object, it does not run the two itween same time.