Search Unity

iTween animation system

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

  1. alimolavi

    alimolavi

    Joined:
    Apr 19, 2010
    Posts:
    35
    can anybody say a example code for moving and rotate an object in a moment ?
     
  2. alimolavi

    alimolavi

    Joined:
    Apr 19, 2010
    Posts:
    35
    when i run unity Debug show a error form this code :
    iTween.RotateTo(gameObject,iTween.Hash("rotation",Vector3.up,"y",.5,"time",4));

    why !?
     
  3. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    You can't ask iTween to use "rotation" and "y" in a rotate call - if you try this your are basically asking it to change the "y" twice in one call. Instead try this:
    Code (csharp):
    1. iTween.RotateTo(gameObject,iTween.Hash("y",.5,"time",4));
     
  4. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    There's examples on here for how to use MoveTo and some more good information here.
     
  5. kwabbott

    kwabbott

    Joined:
    Jun 5, 2007
    Posts:
    151
    I have an car following a path using iTween.MoveTo and iTweenPath, and I want the player to be able to adjust the speed only while staying on the path. MoveTo doesn't let me change speeds and MoveUpdates seems not to wok with paths or speed. Is there a workaround?

    thanks

    Kevin
     
  6. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    P.S. @Pixelplacement, happy birthday!! :)
     
  7. 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.

    Any way to get this done?
     
  8. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Try a custom solution using iTween's PutOnPath()
     
  9. pravinyadav

    pravinyadav

    Joined:
    Jan 24, 2010
    Posts:
    30
    I am working on Iphone and using stab to play audio. I would like to play different audio file depending on situation. I found that stab attaches a audioclip, audioTo gives control on volume and pitch but there is no control to fade out or pause/stop current audio and change audio clip. It will be great if you can give some hint to achieve this effect.
    Thanks,
    Pravin
     
  10. teatime

    teatime

    Joined:
    Jun 16, 2008
    Posts:
    129
    is there currently any way to constrain an object (such as a player character) to a path and have it travel at a constant speed, rather than fluctuate with the spline as seen in the "Path-constrained Characters" example?
     
  11. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Not currently and this has been requested many time before. I'll see if I can get to improving this sometime this year.
     
  12. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Sorry but that functionality goes beyond the scope of what iTween was meant to do. You would need to create your own logic to tackle that. Good luck!
     
  13. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    +1 to @teatime request, I too could OFTEN use the ability to have an object travel at constant speed on a spline/path.
     
  14. Din

    Din

    Joined:
    Jan 11, 2011
    Posts:
    146
    Is it free for now?? If yes can any1 give me a dirrect download link of this? couse i can't find it...
     
  15. IonDave

    IonDave

    Joined:
    Sep 27, 2010
    Posts:
    58
  16. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
  17. Din

    Din

    Joined:
    Jan 11, 2011
    Posts:
    146
    Yeah! I find! it's at the download section of gcode page lol, sry for my inattention.
     
  18. kwabbott

    kwabbott

    Joined:
    Jun 5, 2007
    Posts:
    151
    When using moveTo with a path, is there a way to make the curvature of the path (not the ease type) linear instead of a spline? I need the item I am moving to turn sharp corners.

    thanks

    Kevin
     
  19. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Hi
    I'm going nuts with this one. I'm trying to animate a GUIText using PunchScale. No luck. I just do something as simple as these 2 lines:

    iTween.PunchScale(gameObject, new Vector3(2, 2, 2), 3f);
    iTween.PunchRotation(gameObject, new Vector3(70, 70, 70), 3f);

    this gameObject has a GUIText on it. Nothing happens on screen. Any way to do this?
     
  20. flim

    flim

    Joined:
    Mar 22, 2008
    Posts:
    326
    I bought the iTween Extension and a couple of examples. But when I tried to convert some of the examples using iTween Extension I got error.

    For instance, in the turret example, I tried change from this:

    to this:

    and I got error
    How can I fix it?
     
  21. okimoki

    okimoki

    Joined:
    May 13, 2010
    Posts:
    116
    is there a way to access float named "_clip" on a custom shader attached to an object? How do i itween its value??
    I guess "FloatUpdate" but i cant seem to make it work, i guess im doing something wrong..

     
  22. Borek

    Borek

    Joined:
    May 3, 2011
    Posts:
    4
    Hi there!
    I'm currently using iTween 1.0 for a 2D butterfly, that flies around my screen. The Code looks something like this:
    Code (csharp):
    1.     private void SetupMovement(int numWaypoints)
    2.     {
    3.         List<Vector3> waypoints = new List<Vector3>();
    4.         waypoints.Add(MyTransform.position);
    5.         for (int i = 0; i < numWaypoints; ++i)
    6.         {
    7.             waypoints.Add(GMUtils.GetRndScreenPosition(LayerPos));
    8.         }
    9.         waypoints.Add(MyTransform.position);
    10.  
    11.         // Yeha, um... let's start :)
    12.         Hashtable iTweenOpts = new Hashtable();
    13.  
    14.         // for a list of points to draw a Catmull-Rom through for a curved animation path
    15.         iTweenOpts.Add("path", waypoints.ToArray());
    16.        
    17.         // for whether to automatically generate a curve from the GameObject's current position to the beginning of the path. True by default.
    18.         iTweenOpts.Add("movetopath", false);
    19.        
    20.         // for whether or not the GameObject will orient to its direction of travel. False by default
    21.         iTweenOpts.Add("orienttopath", true);
    22.  
    23.         // for the time in seconds the object will take to look at either the "looktarget" or "orienttopath"
    24.         //iTweenOpts.Add("looktime", 1.0f);
    25.  
    26.         // for how much of a percentage (from 0 to 1) to look ahead on a path to influence how strict "orienttopath" is and how much the object will anticipate each curve
    27.         // iTweenOpts.Add("lookahead", 0.5f);
    28.  
    29.         // for whether to animate in world space or relative to the parent. False be default.
    30.         iTweenOpts.Add("islocal", false);
    31.  
    32.         // restricts rotation to the supplied axis only
    33.         iTweenOpts.Add("axis", "z");
    34.  
    35.         // for the time in seconds the animation will take to complete
    36.         //iTweenOpts.Add("time", 15.0f);
    37.  
    38.         // can be used instead of time to allow animation based on speed
    39.         iTweenOpts.Add("speed", Speed);
    40.  
    41.         // for the shape of the easing curve applied to the animation. Default: InOutCubic?
    42.         // http://www.robertpenner.com/easing/easing_demo.html
    43.         iTweenOpts.Add("easetype", iTween.EaseType.linear);
    44.  
    45.         // for the type of loop to apply once the animation has completed
    46.         iTweenOpts.Add("looptype", iTween.LoopType.loop);
    47.  
    48.         iTween.Init(this.gameObject);
    49.         iTween.MoveTo(this.gameObject, iTweenOpts);
    50.     }
    orienttopath is set and the rotation is restricted to the z-axis, but my butterfly nerver rotates, not even a single degree :( Any idea, whats wrong with iTween or my code?

    Thanks in advance! And thanks for iTween - it already saved me a lot of time :)

    Greetings,
    Borek
     
  23. Mark-Sweeney

    Mark-Sweeney

    Joined:
    Feb 21, 2010
    Posts:
    172
    I'm having problems with iTween.MoveTo on my iPad 1st gen. Two objects are set to move to two locations, however, both stop short.
    Code:
    Pk is supposed to stop at 55.78448 on the Y axis, but stops at 95.81201
    St does the same thing. Any ideas why it's not working properly? I did download the latest iTween this morning.
     
  24. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Interesting, have you tried setting them to local: "isLocal", true?
     
  25. LimeSplice

    LimeSplice

    Joined:
    Jul 15, 2011
    Posts:
    111
    Hi

    I want to be able t loop the following function, until i set a defined end with another function

    Code (csharp):
    1.  
    2. function MoveFormationOne() {
    3.    
    4.     var formationOne : GameObject = GameObject.Find("Enemy1Pool");
    5.     iTween.MoveBy(formationOne, iTween.Hash("x", -50, "time", moveSpeed, "easeType", iTween.EaseType.linear, "delay", 0));
    6.     iTween.MoveBy(formationOne, iTween.Hash("y", -8, "time", dropSpeed, "easeType", iTween.EaseType.easeInOutCubic, "delay", delay1));
    7.     iTween.MoveBy(formationOne, iTween.Hash("x", 50, "time", moveSpeed, "easeType", iTween.EaseType.linear, "delay", delay2));
    8.     iTween.MoveBy(formationOne, iTween.Hash("y", -8, "time", dropSpeed, "easeType", iTween.EaseType.easeInOutCubic, "delay", delay3, "onComplete", "LoopIt"));
    9. }
    10.  
    11.  
    I thought that by pointing the last in the loop to go to function LoopIt(), that looks like this...
    Code (csharp):
    1.  
    2. function LoopIt() {
    3.     MoveFormationOne();
    4. }  
    5.  
    ..that it would loop, but it doesn't. So how do i go about looping the first function above indefinitely?
    Thanks
     
  26. LimeSplice

    LimeSplice

    Joined:
    Jul 15, 2011
    Posts:
    111
    *Nice bump*. I'm really stuck on my issue above - tried everything, but 'onComplete' doesn't seem to work for me. Am I spelling it/using it incorrectly?

    Please help before I rip all of my hair out!

    Thanks!
     
  27. LimeSplice

    LimeSplice

    Joined:
    Jul 15, 2011
    Posts:
    111
    Okay found the solution - I needed to put ""onCompleteTarget": gameControl" into the last line. (where gameControl is the gameObject this script lives on).

    But I'm confused by this - I thought you only needed this if the function the onComplete needs to point to is on ANOTHER game object script, not the current script???
     
  28. pixelmoon

    pixelmoon

    Joined:
    Sep 13, 2010
    Posts:
    27
    Hi…I´m having some issues with iTween.Pause.
    After triggering a collider, I want a platform start moving. No problem:



    Code (csharp):
    1. OnTriggerEnter (collisionInfo: collider){
    2.    
    3.     if(collisionInfo.gameObject.tag == "colliderleftdoor"){
    4.          ItweenLeftCorridor ();    
    5.     }
    6.  
    7. }
    8.    function ItweenLeftCorridor ()
    9.  
    10.     {
    11.        
    12.     iTween.MoveTo (firstplatform,{"y":1,  "time":2, "looptype": "pingpong" , "easetype": "linear"});
    13.     iTween.MoveTo (secondplatform,{"y":-1,  "time":2, "looptype": "pingpong", "easetype": "linear"});
    14.     iTween.MoveTo (thirdplatform,{"y":-2,  "time":2, "looptype": "pingpong", "easetype": "linear"});
    15.  
    16.     }
    The platform starts moving...

    I want the platform stop moving...so I use OntriggerExit:

    Code (csharp):
    1. OnTriggerExit (collisionInfo: collider){
    2.    
    3.     if(collisionInfo.gameObject.tag == "colliderleftdoor"){
    4.          StopItweenLeftCorridor ();    
    5.     }
    6.  
    7. }
    8.  
    9.   function StopItweenLeftCorridor ()
    10.  
    11.     {
    12.            
    13.     iTween.Pause (firstplatform);
    14.     iTween.Pause (secondplatform);
    15.     iTween.Pause (thirdplatform);
    16.  
    17.     }
    Platforms stops moving, great!!…but what if I want to move tha platforms again from the point where they paused? I enter the collider in order to call the ItweenLeftCorridor function... but nothing happens.

    On the inspector, for my GameObjects that I´m pausing, I can see "isPaused" box checked and the iTween script is not enabled (I see this is defined on the iTween.cs, where iTween.Pause has "item.isPaused=true" and "item.enabled=false")…Any clue what am I doing wrong?

    Thanks a lot and once again, congrats and hat off for this amazing tool!!
     
  29. LimeSplice

    LimeSplice

    Joined:
    Jul 15, 2011
    Posts:
    111
    Hi - just a question about hard-coding path co-ordinates... how? lol

    I normally use:

    Code (csharp):
    1.  
    2.  
    3. var pathA1 : Vector3[];
    4.     iTween.MoveBy(gameObject,{"path": pathA1, "time": 2, "orienttopath": false, "easetype": iTween.EaseType.easeInOutCubic});
    5.  
    I don't want to expose and enter the path variables in the inspector - as there will be ALOT, and will not have to change, so figured it would be easier just to enter the numbers into the script.

    I'll be needing 3 points along the path e.g. (0,0,0), (0,100,0), (100, 100,0).

    I've tried this, but doesn't work and OnDrawGizmos doesn't recognise either:
    Code (csharp):
    1.  
    2. var pathA1 : Vector3[] = [Vector3(0, 280, 0), Vector3(1, 0, 0), Vector3(100,300,0)];
    3. var pathA2 : Vector3[] = [Vector3(0, 280, 0), Vector3(100, 90, 0), Vector3(90,9,944)];
    4. var pathA14 : Vector3[] = [Vector3(0, 280, 0), Vector3(-120, 50, 0), Vector3(100,100,0)];
    5.  
    Thanks for the advice.
     
    Last edited: Aug 24, 2011
  30. oliverdb

    oliverdb

    Joined:
    Jan 30, 2010
    Posts:
    165
    EDIT:

    My bad...Timescale was 0.... DOUGH
     
    Last edited: Aug 25, 2011
  31. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    Some of my wishes:

    -For a PunchVector3/ShakeVector3, or PunchValue/ShakeValue

    -For ValueTo to be a little more user friendly, without the onupdate callback.
    for example, it'd be nice if you could do:

    myVar = iTween.ValueTo(gameObject, startValue, endValue, amountOfTime);

    or something similar.
     
  32. qholmes

    qholmes

    Joined:
    Sep 17, 2010
    Posts:
    162
    I am using some iTween Functions in Play Maker.. I just ran into this issue.. Thought i would post it here too.. It might just be a simple thing that i dont know..

    When i use the iTween Move To on a child object it does not work... It goes to some arbitrary location i think or it seems.. Maybe a world position? And i have Local checked too..

    Is this just a limitation of iTween? or have i done something really dumb or is there something broken in the Play Maker version?

    It is going to a World position.. changing the Space does not seem to matter it always goes to World..

    Q
     
    Last edited: Sep 7, 2011
  33. qholmes

    qholmes

    Joined:
    Sep 17, 2010
    Posts:
    162
    So i think i figured it out.. the property name that was used to build the hash table was "space" instead of "islocal" that seemed to work.. not sure if "space" was an old property or not.

    Q
     
  34. avillago

    avillago

    Joined:
    Jun 11, 2011
    Posts:
    1
    Hello!! I'm new to Unity, and because of a project that involved the use of a rail system I started using iTween, and it worked awesome!!!

    After that I had to use it again for a game my team and I developed for an IndieCade Game Jam on a 3D phone, and the crowd was astonished.

    Now I need help with a couple of issues. I'm moving a flying game object on an iTweenPath and I have it always facing forward towards the path.

    The 2 issues that I'm facing are:

    How can I get the object to bank left or right whenever there's a curve on the path???

    How can I change the height of the path between path nodes? (say that I have a structure/mountain between the 2 points, right now it's going through the structure / mountain)

    Thanks for any help
     
  35. CoCoNutti

    CoCoNutti

    Joined:
    Nov 30, 2009
    Posts:
    513
    Hey Bob
    It's been a while but I'm getting back into the Unity-swing of things.

    I have a question regarding controlling an object using Touch,Input commands and Itween. I need to move a crate (how original) in my scene. At the moment it works fine with the old "transform.Translate" in Update. But the effect is pretty boring, with the object following the touch, but it's bland.

    I'd like to use iTween to do this instead. I've played around with a few attempts with MoveAdd and MoveBys but I can't get these to work progressively/continuously in the Update (just as it would if i used Input.GetKey for keyboard).

    Is it possible to use iTween in this way at all? Or should I seek other alternatives?

    The final effect I'm going for is twofold:
    1. When the player touches (anywhere) on screen, the crate moves to the position of where the finger is - i.e. it follows the finger (if not lifted from the screen), and
    2. If the player just taps once on screen, the crate moves to that tap position as well.
    I'd like to have a slight delay on both moves, with an easeOut at the end of each movement.

    Any suggestions would be a great help. Thanks!!
     
  36. cocoa

    cocoa

    Joined:
    Jan 12, 2012
    Posts:
    1
    I got the same problem :(
    I can use only 1 action at the sametime. If not, it works not what i expected. (When I use one by one with delay, it works fine..)
    Are there anyone who can help me?
     
  37. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    853
    This has been asked before but wasn't answered - is there a way to set up a path with sharp corners rather than soft curves? I want to set up a character to move along the sides of a geometrical object. I guess one possible workaround would be creating a path for each side and put the character on the adjacent path once I reach the end of the current one, but that sounds rather impractical.
     
  38. mikolo

    mikolo

    Joined:
    Nov 27, 2009
    Posts:
    249
    My new game "Spaceketball" is using the Accurate Lob from iTween! Its really a cool extension!
     
  39. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    Can iTween play animations on gameObjects which are coming from other programs like maya?
    Does doing this work with timescale set to 0?
    Also if this is possible how do you do it?

    Thanks,
    WightWhale
     
  40. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    I have the same question as WightWhale. Can Unity's default Animation class be played using iTween?
     
  41. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Is iTween affected by timescale; as in, can I use iTween when game is paused/timeScale = 0?
     
  42. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    has anyone heard any news on the release of the new beta of iTween? The one without the garbage collection of the current version
     
  43. johnnydj

    johnnydj

    Joined:
    Apr 20, 2012
    Posts:
    211
    I'm banging my head against the walls for days...
    I've tried many approaches in making a ball roll from point A to point B.

    Is there a way to have to ball sit on the ground, and actually roll from point A to point B?
    The terrain isn't really flat, and I have no idea how to have the ball sit on the ground, while moving from point A to point B.

    Any help would be appreciated. :(
     
  44. Chimera3D

    Chimera3D

    Joined:
    Jan 27, 2012
    Posts:
    73

    Hey, you might want to use physics for a ball. Try using rigidbody.AddTorque.

    Yeah, I need that feature too.
     
    Last edited: May 9, 2012
  45. Irishsun530

    Irishsun530

    Joined:
    Jun 23, 2012
    Posts:
    13
    Hello,

    I've posted in various locations. Hopefully someone will help :( I found a way to finally make a trap door the thing is I need to use iTween. The bad part after installing it, it shows up in project but not in Component. I need it to run Javascript, also isn't there supposed to be something called iTween event script as well?

    Please oh Please help
     
  46. Micz84

    Micz84

    Joined:
    Jul 21, 2012
    Posts:
    451
    I have small problem with itween i set it to move object in a grid 1 unit per grid cell and it works fine (i use MoveTo method), but i set time for such a move to 0.1 second but it move much slower than that on my android device when i build and run it. I have asus transformer.

    @Irishsun530 do not post same question in multiple threads. You call iTween like this:
    iTween.MoveTo(<gameObject which you want to animate>, <args array>) ;

    Thanks to my answer to Irishsun i found solution to my problem. Previously i was using MoveTo(gameobject,position,time); and have manually iterated through array of points, when i have used path everything works fine.
     
    Last edited: Aug 16, 2012
  47. Luisdiv

    Luisdiv

    Joined:
    Sep 17, 2012
    Posts:
    8
    Regarding the two tweens at same time with a rigidbody issue,

    Did you find a solution to this?? Please help!
     
  48. ice99

    ice99

    Joined:
    Feb 8, 2013
    Posts:
    9
    First of all thanks a lot for such useful script.

    But i found a problem in my task.
    I make simplest loop path scene and tried to export it to FLASH, and receive 4 errors.
    1-------------
    Usage of a type or method not supported by Unity Flash.
    * Details: Invokes an unsupported method !!0 System.Linq.Enumerable::FirstOrDefault<iTweenEvent>(System.Collections.Generic.IEnumerable`1<!!0>,System.Func`2<!!0,System.Boolean>) on type System.Linq.Enumerable
    * Source: C:\Unity4\1\Assets\iTweenEditor\iTweenEvent.cs(?H96 at line : 0
    2---------------------
    Usage of a type or method not supported by Unity Flash.
    * Details: Invokes an unsupported method System.Guid System.Guid::NewGuid() on type System.Guid
    * Source: C:\Unity4\1\Assets\iTweenEditor\iTweenEvent.cs(?H218 at line : 0

    3----------------------
    Usage of a type or method not supported by Unity Flash.
    * Details: Invokes an unsupported method System.String System.Guid::ToString() on type System.Guid
    * Source: C:\Unity4\1\Assets\iTweenEditor\iTweenEvent.cs(?H218 at line : 0

    4--------------------
    Error building Player: Exception: Validation step FlashDotNetAPIValidationRule Failed!

    I think that problem in depth and figure it out can only developer (not noob like me)
    I've found similar problems and found a solution for U3.5
    http://blog.almostlogical.com/2011/12/22/unity-to-flash-exporter-with-itween/

    But in U4 i receive an errors
     
  49. G.G.

    G.G.

    Joined:
    Feb 28, 2013
    Posts:
    5
    Hi, i am new of Unity 3D community.
    I have try itween and found it fantastic.

    But need an explanation for orienttopath's function.
    Example of different behavior with 3D path (change x-y-z on every waypoint of path):
    1) man climbing an inclined plane (for example a stair): man when walk stay parallel to y global axys (not parallel to orthogonal plane ).
    2) car climbing an inclined plane (for example run on a mountain): the car stay parallel to orthogonal plane (not parallel to y global axys).

    Orienttopath function work fine with example 1, and need lookat and rorateby with case 2. But when i need to apply "lookat and rotateby" for >10 car gets boring to use itween for the case 2.
    Now orienttopath need probably an upgrade for the 2 different behavior, 1 with this current itween, and case 2 with an orienttopath for the x-z plane and y-z plane (can overlap the two behaviors).

    What need to make orienttopath in the 2 behavior case:
    1) lookat a close new point: moveto new x-y-z and rotateby alpha angle (alpha is the angle between the front of gameobject and the path's tangent of new point).
    2) lookat a close new point: moveto new x-y-z and rotateby alpha angle + rotateby beta angle (beta is the angle between vertical of gameobject and the global axys y).

    Now, to simulate the case 1 can use:
    //tLook = ease(0,1,percentage+lookAheadAmount);
    tLook = ease(0,1, Mathf.Min(1f, percentage+lookAheadAmount));

    To simulate the case 2 (alpha and beta rotation) we can for example use:
    //tLook = ease(0,1,percentage+lookAheadAmount);
    tLook = ease(0,1, Mathf.Min(3f, percentage+lookAheadAmount));

    This allows to rotate the game object into a climb plane with alpha and beta angle...but create also the bug of rotation on start of the path.
    Probably can solve-it with an if percentage ..> 0% path or 100% path use case 1, else if player want case 1 use 1f or if player want case 2 use 3f.

    bbye
    (sry for my bad english)
     
  50. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649