Search Unity

iTween animation system

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

  1. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Yup! Take a look at the "path" property for Move. :)
     
  2. simone007

    simone007

    Joined:
    Oct 30, 2008
    Posts:
    221
    I love it, but I am having difficulty using some commands with GuiTextures (like with PunchScale, PunchPosition, MoveFrom commands).
    Some commands seem to work correctly only with GUITextures attached to GameObjects with no other parents...

    How should I configure the GameObject in order for its attached GUITexture to be an ideal target of an iTween command?

    Please help

    Simone
     
  3. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    A simple GameObject with a GUITexture attached should work fine. What issues are you having? Have you checked out the example on the support site?
     
  4. jhem00

    jhem00

    Joined:
    Jul 16, 2010
    Posts:
    29
    Code (csharp):
    1. iTween.MoveToBezier(gameObject,{"bezier":[Vector3(1,0,.5), Vector3(0,0,1),Vector3(-1,0,.5),Vector3(0,0,0)], "time":4, "transition":"linear"});

    how can i convert it to the new syntax? sorry still new to game dev and iTween :)
     
  5. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Here ya go:
    Code (csharp):
    1. var path : Vector3[];
    2.  
    3. function Start(){
    4.     path = new Vector3[4];
    5.     path[0] = Vector3(1,0,.5);
    6.     path[1] = Vector3(0,0,1);
    7.     path[2] = Vector3(-1,0,.5);
    8.     path[3] = Vector3(0,0,0);
    9.     iTween.MoveTo(gameObject,{"path":path,"time":4,"easetype":"linear"}); //if you do not want the object to animate to the first point on the path add "movetopath":false
    10. }
    11.  
    12. function OnDrawGizmos(){
    13.     iTween.DrawPath(path);
    14. }
    You should take a look at the "Move on Path" example as well: http://itween.pixelplacement.com/examples.php#movingonpath

    Hope this helps.
     
  6. jhem00

    jhem00

    Joined:
    Jul 16, 2010
    Posts:
    29
    woah! that was so fast! you really work hard! I just started unity and itween. Its a great kickstart for me! Btw ill use it for my thesis this semester. Thanks again!
     
  7. jhem00

    jhem00

    Joined:
    Jul 16, 2010
    Posts:
    29
    Do you have an idea what code should I use if I want to animate a fish? to make it more realistic?

    Code (csharp):
    1. var path : Vector3[];
    2.  
    3. function Start(){
    4.     path = new Vector3[4];
    5.    path[0] = Vector3(1,0,.5);
    6.    path[1] = Vector3(0,0,1);
    7.    path[2] = Vector3(-1,0,.5);
    8.    path[3] = Vector3(0,0,0);
    9.    iTween.MoveTo(gameObject,{"path":path,"time":4,"easetype":"linear"}); //if you do not want the object to animate to the first point on the path add "movetopath":false
    10. }
    11.  
    12. function OnDrawGizmos(){
    13.    iTween.DrawPath(path);
    14. }
    this is good but the fish's head stays on one direction. please help me thanks!

    btw the fish is a trigger.
     
  8. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    I don't really have a ton of time to write out a solution to your issue but you could try cutting the fish into 3 sections and have them all follow the same path with "orientToPath" set to true.

    Just a thought.
     
  9. simone007

    simone007

    Joined:
    Oct 30, 2008
    Posts:
    221
    I have downloaded almost all the examples.

    Everything works fine in my project, except for some (not all, that's the strange thing) GUITextures. It simply happens that the iTween command is not applied, nothing happens (punchScale in this example).

    I checked the editor (while the project is running) and I noticed that at runtime the iTween script becomes correctly attached to the GameObject (parent of the GUITexture) for all the length of the animation, but the GUITexture does not animates.

    In my project, each GUITexture is contained (obviously) in an empty GameObject. The GameObject is also the child of other GameObjects. I think this may be the problem.

    Please note that all my GameObjects have Scale (0,0,0), Position (0,0,0) and Rotation (0,0,0).

    Thanks for help,
    Simone
     
  10. rikochet

    rikochet

    Joined:
    Aug 19, 2010
    Posts:
    5
    Hey I have a question. I'm doing a pretty complex nested tween based on the "Moving on a path example." Basically, I have a tween that is moving a container in a specified path through the level. Enemies spawn and move along a path within this container in another "move on path" (child of the moving tween), but with islocal being true so that it's movements follow the parent. I'm noticing that orienttopath does not work when islocal is set to true in this scenario, any ideas?
     
  11. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Hey guys, my new son should be here any day now so I'm focusing on that for right now. I'll help you out as soon as I can!
     
  12. rikochet

    rikochet

    Joined:
    Aug 19, 2010
    Posts:
    5
    No worries and congrats! I did a messy solve that works for now:

    Under ApplyMoveToPathTargets(), I added a conditional if "islocal" adding the position of my container tween:

    Code (csharp):
    1.  
    2.             if(tweenArguments.Contains("islocal")  (bool)tweenArguments["islocal"]){
    3.                 GameObject TrainTemp = GameObject.Find("Train");
    4.                 tweenArguments["looktarget"] = path.Interp(Mathf.Clamp(tLook,0,1)) +  TrainTemp.transform.position;
    5.                 print(path.Interp(Mathf.Clamp(tLook,0,1)));
    6.             } else {
    7.                 tweenArguments["looktarget"] = path.Interp(Mathf.Clamp(tLook,0,1));
    8.             }
    9.  
    *edit* sorry, the indentation isn't translating over here very well
     
  13. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Hey, I dont know what you did or because I'm using Unity 3 now, but iTween is working perfectly when I build my game onto my iPhone now. No big frame drops at all, its quite smooth and I love it. Thanks for this tool again. :D
     
  14. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    This is odd. If you get a chance can you send me a sample project so I can investigate?
     
  15. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Can you send me a sample of your project so I can investigate this and get it fixed in iTween? Thanks!
     
  16. Pyroman311

    Pyroman311

    Joined:
    Aug 14, 2010
    Posts:
    87
    Just wondering, since I am about to buy these two examples:


    Animating 2D Menu one: How well will this work/look on an iPhone? I don't want it lagging behind and not showing smooth movement (3G and 4, possibly on 3G).


    Sliding menu one: Does it include a way to switch between each screen from a finger swipe? I want it to act just like default menu's that you flick through, not by pressing an arrow button.

    One last thing: How easy would it be to link the two? Like start off by showing the main menu animating in, then when the player hits "Play", it shows the sliding menu to pick what level/weapon?


    Awesome examples, btw! Thanks
     
  17. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    I just tested the Animating 2D on a 1st Gen iPhone (yup the slowest one) and it runs pegged at over 29.70 FPS which is flawless performance.

    The Sliding Menu example does not include flick gestures.

    You could easily load different scenes the first being an animation of GUITextures and then the next being a version of the Sliding Menu example.

    Please keep in mind that as the site says, the examples that are for sale only target a specific usage of iTween to help you understand and hopefully inspire you for useful solutions where iTween could help you on your projects. They are not meant as reusable solutions. But with a little effort you could easily pull off solutions like the ones demonstrated.

    I do plan on releasing some high-end iTween powered prefabs for http://www.unityprefabs.com/ soon however.

    Good luck with things!
     
  18. Pyroman311

    Pyroman311

    Joined:
    Aug 14, 2010
    Posts:
    87
    But I could definitely implement flick gestures myself, correct?


    Now off to figure out how...

    :)
     
  19. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Absolutely! I have an old and buggy script on my other code repository that I used for an isometric game if you'd like to take a look: http://code.google.com/p/pixelplace...com/pixelplacement/scripts/iSwipeIsometric.js

    Apparently this needs another thing I made here: http://code.google.com/p/pixelplace...unity/com/pixelplacement/scripts/iTouchGUI.js

    Sorry this is "old" and horribly done stuff at this point...
     
  20. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Just wanted to update everyone and let you know that a few new examples have been added to the support site to help get you up to speed. If you have any example requests please let me know!

    Take a look at the new examples here: http://itween.pixelplacement.com/examples.php
     
  21. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    All movement and rotation based iTweens now correctly work with Rigidbodies (if
    they are present) by doing their animations in FixedUpdate() and by using
    MoveRotation() and MovePosition()... think pinball flippers, bullets, etc!!

    -and-

    Color methods can now be sent a "namedcolorvalue" as a NamedColorValue or
    "string" for operating on the specular, emissive and reflective colors of a material!!
     
  22. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    I don't know how I missed this thread, but this looks very interesting and I'd like to give it a spin. Is there somewhere I can download the documentation?
     
  23. Yann

    Yann

    Joined:
    Oct 20, 2007
    Posts:
    432
    @pixelplacement1 : I sent you a PM and an e-mail regarding the download links, did you receive them ?
     
  24. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Responded to both :)
     
  25. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Nope, the docs are only available on the site. Since they are simple HTML you could easily download them and get yourself a local copy. But I'm always changing things with iTween so I found it better to keep the docs on the site only.
     
  26. defjr

    defjr

    Joined:
    Apr 27, 2009
    Posts:
    436
    Bob,

    You own.
     
  27. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Earl,

    I try.

    :D
     
  28. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Hmm...one thing I noticed, that is puzzling to me, is that the first time iTween is used in a scene, a stutter is noticeable, but any use after that its smooth....why is this? Is it loading at the beginning or something?
     
  29. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    It's not. It could be Unity's initial AddComponent call when iTween starts. I'd suggest just a dummy iTween right off the bat. Unity always stutters when it first starts. You could try a slight delay on everything until Unity initializes everything.
     
  30. pixelplacement1

    pixelplacement1

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

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    what do u mean a dummy iTween?
     
  32. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Just a call that doesn't move anything:

    Code (csharp):
    1. iTween.MoveTo(gameObject,transform.position,0);
    Just to get iTween cached.

    Just a thought, not something I'm guaranteeing will work but the theory is there.
     
  33. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Cool, Ill try that.
     
  34. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    hmm, does the iTween code have to be on the object that needs to be animated? Can't I reference it and replace
    Code (csharp):
    1. iTween.MoveBy (Chara, Vector3(blah), time blah);
     
  35. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Nope. You can target any GameObject. For example "Chara" could be camera.main.gameObject. Cool?
     
  36. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Not exactly sure, but let me give you actual use I want.

    Code (csharp):
    1. var comboGui : SpriteText;
    how would iTween reference that variable using this function:

    Code (csharp):
    1. PunchScale(GameObject target, Vector3 amount, float time);
    EDIT: Scratch all what I asked. It wasnt working because I forgot to put iTween before PunchScale... lol
     
  37. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    One thing I do want to know about though is that I have noticed when iTween is doing something with that gameObject already, it doesnt override it with a new input. For eg, Im using iTween to move my character backwards when being hit. Thing is if an enemy hits the player and he begins moving backwards, then before that movement ends another enemy hits him, it doesnt respond to the other enemies attack...

    Does this sound familiar to you pixel?
     
  38. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Yup. iTween "doesn't destroy duplicates" on purpose to make sure it plays well with usage inside of Update() methods. To counter this you have a few options:

    1. Utilize iTween's Stop() methods first then apply your new iTween.
    2. I assume you are using MoveBy() so just put the slightest amount of random onto the value you give it (e.g. iTween.MoveBy(go,new Vector3(0,0,2+Random.Range(0,.1)),time);
    3. Use MoveUpdate and have it lock the character's position to the value of a null object. Every impact will reposition the null by a certain amount causing the character to "slide" to this new position to match the null.

    Cool?
     
  39. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Cool, I'll try that. Something else, this should work right?

    Code (csharp):
    1. iTween.FadeTo(comboGui.gameObject, 0, 1);
    But nothing seems to happen for me..
     
  40. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    What exactly is "comboGui"?
     
  41. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    A text gameObject that tracks combo score.
     
  42. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Do you mean a GUIText?
     
  43. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Sprite Text from EZGUI, which I guess is almost the same thing.
     
  44. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Sorry never used EZGUI I can't support iTween with something I've never used.
     
  45. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    It has the same functionality, but does more than a GUIText. It just allows me to use texture atlases.

    Anyways, what would be required for a gameObject for it to be faded?
     
  46. pixelplacement1

    pixelplacement1

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

    crafTDev

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

    pixelplacement1

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

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Yea, I just need to use the Transparent - Vertex Colored shader instead of my custom one.
     
  50. z3r0

    z3r0

    Joined:
    Sep 27, 2010
    Posts:
    1
    iTween is awesome :)

    I need a little help with PutOnPath.

    I am using this code
    Code (csharp):
    1. iTween.PutOnPath(gameObject , aTransforms,  Speed );
    - aTransform is the array that makes the spline
    - Speed is the percentage that I use as a speed control variable.

    It works ok but I want the object to also rotate along the line following the curvature.
    Is there something like “orientToPath” like in the iTween.MoveTo command or do I have to use additional functions?

    I am fairly new to Unity and to this forum so I appreciate your help.