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

HOTween: a fast and powerful Unity tween engine

Discussion in 'Assets and Asset Store' started by Demigiant, Jan 7, 2012.

  1. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    New release: HOTween v1.1.002

    - Fixed OverwriteManager bug (identical plugins inside the same Sequence were sometimes overwritten if calling GoTo).

    @burost: sorry for the bug. This update fixes it :) As usual, to get the latest version go to HOTween's website. Forgot to check isEmpty, will do it for next update.
    By the way, you don't need to add a Pause to the Tweeners you add to a Sequence, since they get paused automatically until you start the Sequence.
     
  2. burost

    burost

    Joined:
    May 15, 2012
    Posts:
    5
    Thanks for the quick update!
     
  3. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hey, I'm glad to "announce" that Baroni (Rebound Games) included HOTween in the next update of his simple and effective Simple Waypoint System :)
     
  4. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Hey, I'm back again...

    I have been trying to figure out how to move a gameobject forward but cant seem to get it to work the way I want:
    Code (csharp):
    1. HOTween.To(thisTransform, 1, "position", Vector3(0,0,1));
    That only moves it to position x=0, y=0, z=1, which is not what I want. I want to move one position forward...help?
     
  5. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hey jrricky,

    to use a value as a "relative displacement" instead than the actual value to reach, you have to use the "isRelative" parameter, which in this case means adding a "true" as the last parameter :)
    Code (csharp):
    1.  
    2. HOTween.To(thisTransform, 1, "position", Vector3(0,0,1), true);
    3.  
     
  6. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    New Update: v1.1.003

    - Fixed PlugRect bug (y value was animated incorrectly)

    As usual, the Asset Store version will be updated later. To grab the latest version go to HOTween's website.
     
  7. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Haha, thanks Daniele! I hope you like the image in my thread (and soon on the Asset Store), and that you will have some donations :)
     
    Last edited: May 29, 2012
  8. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hehe, thanks to you Baroni (it would be cool to go beyond 6 donations :p), and I definitely like the image I saw. Turbotween! :D I also will probably be a client soon, seen that your Simple Waypoint System looks absolutely perfect for my next game :)
     
  9. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    I wanted to donate anyways, drop me a pm if you're interested to be the first customer of v2 :)
     
  10. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    PM on the way, but mind everybody: the donation sentence didn't want to be a critique to any user of any kind! ;) I know donations are clumsy: me too, I used FlashDevelop for almost a year before starting to donate :p
     
  11. bandingyue

    bandingyue

    Joined:
    Nov 25, 2011
    Posts:
    131
    nice job,i will have a try
     
  12. matte.szklarz

    matte.szklarz

    Joined:
    May 29, 2012
    Posts:
    10
    I had the same problem has 39thstreet. I had a script I converted from iTween that would take a function and pass it to the tween function with a time set to 0.0. i.e.

    JumpCam( target ) {
    var time = 0.0;
    tweenCam( target, 0.0 )
    }

    TweenCam( target, time ) {
    do tween.
    }

    This is drastically oversimplified, there are a few more versions of jumpcam and tweencam (I'm big on function overloading).

    Anyway, sending zero through broke the system, and wouldn't allow the function to complete. If HOTween converted 0 to 0.0001 or a Debug.Log( "warning: hotween doesn't accept 0" ) error had been thrown, it might have saved some head banging.
     
  13. matte.szklarz

    matte.szklarz

    Joined:
    May 29, 2012
    Posts:
    10
    **** UPDATE ***

    Found the post about this being fixed, but HOTween with a time of 0.0 still does NOT fire the oncomplete() for some reason. Locks up the rest of the code.
     
  14. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Ok, that kinda works. It just doesnt move in the direction based the gameobjects forward setup - no matter where the object is looking, it doesnt move forward by 1, just adds 1 to z position. Which means the wrong code setup...help again? :)

    Thanks

    EDIT: I figured it out by doing this:
    Code (csharp):
    1.  
    2. HOTween.To(thisTransform, 1, "position", thisTransform.forward * 1, true);
    3.  
    But then I tested it and it doesnt work for my situation because HOTween seems to override Colliders and go through them - unless there is a way to move the objects with HOTween while obeying to the colliders, its of no use atm :/
     
    Last edited: May 30, 2012
  15. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    New Update: HOTween v1.1.004

    - Fixed bug with 0 duration tweens not completing correctly (and thus not dispatching OnComplete event).

    As usual, grab the latest version from HOTween's website.

    @matte.szklarz: this fixes your issue, sorry for not noticing that earlier.

    @jrricky: a tween engine has nothing to do with physics or colliders. You should manage colliders separately, meaning you can check for OnCollisionEnter or stuff like that, and react accordingly (like stopping/killing a tween if its target hits something) :p
    And yes, relative tweens add the given value to the current one (be it a position or anything else). That's intended behaviour :)
     
  16. matte.szklarz

    matte.szklarz

    Joined:
    May 29, 2012
    Posts:
    10
    Nice!

    I got another issue that is plaguing me though, I'm using the basic

    Code (csharp):
    1.  
    2. HOTween.To( this.transform, time, new TweenParms()
    3.         .Prop("position", refCam.position)
    4.         .Prop("rotation", refCam.rotation)
    5.         .Ease(EaseType.EaseInOutQuad)      
    6.                 .Loops(1)
    7.         .OnComplete(OnCompleteTween, refCam )
    8. );
    9.  
    And the position tween works as expected, but the rotation does not. It should make the camera tween up and to the right, but it causes the camera to do a somersault forward. AND, in reverse, it doesn't somersault-backwards, it instead takes the long-way-around, i.e. needs to turn -90 but it turns 270.

    I did a few blind trials of changing rotation to localRotation, eulerAngles, and changing the and changing the local and global scale.

    I might be able to solve this by changing the way the refCam(s) (a dummy for pos/rotation reference for tweening to) are in the heirarchy, but I don't want to ;)

    When I say "work as expected" it's because this set-up "just worked" in iTween. What's the difference?
     
  17. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hey matte,

    I tried to replicate your issue, but here it's working correctly. Could you send me a package with a sample scene that shows this bug? This way I'll be able to look at it and see what's wrong with HOTween.
     
  18. badawe

    badawe

    Joined:
    Jan 17, 2011
    Posts:
    297
    Any news about Bezier?

    I have one game object and i want this to move from one point to another point, but passing throw another point making a bezier curve.
    Can i do something like that?
     
  19. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hey badawe,

    I'm sorry, but no bezier curves for now, only catmull-rom. They're easier to use, while implementing bezier curves would necessarily need a curve editor, and thus a lot of stuff to do.
     
  20. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    I was wondering if I wanted to tween a simple unsigned integer using your system, how would I go about doing that? Also, how would I tween it as Time.timescale independent? For example, I want to twen a number on a pause menu. Thank you.
     
  21. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hey AbsurdHart,

    to simply tween an integer, you could go the easy way, and do:
    Code (csharp):
    1.  
    2. // Here we tween the integer myClass.myInt from its current value to 200
    3. // Parameters are: target, duration, target property (or public field) to tween, end value
    4. HOTween.To(myClass, 1, "myInt", 200);
    5.  
    To add a timescale-independent tween you'll have to use the TweenParms way instead, and do:
    Code (csharp):
    1.  
    2. HOTween.To(myClass, 1, new TweenParms().Prop("myInt", 200).UpdateType(UpdateType.TimeScaleIndependentUpdate));
    3.  
    More about the basics here :)
     
  22. marjan

    marjan

    Joined:
    Jun 6, 2009
    Posts:
    563
    Sorry to jump into the stripping boat.
    I downloaded the latest Version for Hotweenmicro 1.1.004, because i could not use the highest stripping level with the normal Hotween.
    To my surprise it did not compile, too. So i made an empty project, set it to strip max and it compiles.
    As soon as i add the Hotween Micro folder, i get this error:


    Code (csharp):
    1. UnityException: Failed assemblies stripper: /Applications/Unity/Unity.app/Contents/Frameworks/Mono/bin/mono "/Applications/Unity/Unity.app/Contents/Frameworks/Tools/UnusedBytecodeStripper/UnusedBytecodeStripper.exe" -l none -c link -out output -x "/Applications/Unity/Unity.app/Contents/Frameworks/Tools/UnusedBytecodeStripper/link.xml" -d "Temp/StagingArea/Data/Managed" -x "tmplink.xml" current dir : Temp/StagingArea/Data/Managed
    2.  result file exists: False
    3. stdout:
    4. stderr: Unhandled Exception: Mono.Linker.ResolutionException: Can not resolve reference: System.Reflection.Emit.OpCode System.Reflection.Emit.OpCodes::Ldind_I1  at Mono.Linker.Steps.MarkStep.MarkField (Mono.Cecil.FieldReference reference, System.Object markedby) [0x00000] in <filename unknown>:0   at Mono.Linker.Steps.MarkStep.MarkInstruction (Mono.Cecil.Cil.Instruction instruction, Mono.Cecil.MethodDefinition markedby) [0x00000] in <filename unknown>:0   at Mono.Linker.Steps.MarkStep.MarkMethodBody (Mono.Cecil.Cil.MethodBody body) [0x00000] in <filename unknown>:0   at Mono.Linker.Steps.MarkStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x00000] in <filename unknown>:0   at Mono.Linker.Steps.MarkStep.ProcessQueue () [0x00000] in <filename unknown>:0   at Mono.Linker.Steps.MarkStep.Process () [0x00000] in <filename unknown>:0   at Mono.Linker.Steps.MarkStep.Process (Mono.Linker.LinkContext context) [0x00000] in <filename unknown>:0   at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x00000] in <filename unknown>:0   at UnusedBytecodeStripper.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
    5.  
    6. UnityEditor.MonoProcessUtility.RunMonoProcess (System.Diagnostics.Process process, System.String name, System.String resultingFile)
    7. UnityEditor.MonoAssemblyStripping.MonoLink (BuildTarget buildTarget, System.String managedLibrariesDirectory, System.String[] input, System.String[] allAssemblies, UnityEditor.RuntimeClassRegistry usedClasses)
    8. UnityEditor.HostView:OnGUI()
    This is in Unity 3.5.2, Mac, Lion with player set to iOs, Armv7 only, iPad, only, .Net 2 subset.
     
  23. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    New update: HOTween v1.1.005

    - Fixed bug where PlugQuaternion wasn't using "shortest" available rotation. This bug was present only in non-relative and non-Beyond360 rotation tweens.
    - HOTweenMicro only: fixed HOTweenMicro not being compiled with correct symbols (MICRO compilation symbol was missing - bug introduced when moving from MonoDevelop to Visual Studio), and thus not working on iOS with max stripping level.

    As usual, the latest version can be found on HOTween's website.

    @marjan: ouch, sorry for that! When I moved from MonoDevelop to VisualStudio, the conditional compilation symbols got lost, and I didn't realize it. I just fixed it: get the latest HOTweenMicro v1.1.005.
     
    Last edited: Jun 6, 2012
  24. marjan

    marjan

    Joined:
    Jun 6, 2009
    Posts:
    563
    That was quick, thanks a lot, its working.
     
  25. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    Thanks for the quick response. I was wondering if let's say myInt is stored like this in the myClass class:

    Code (csharp):
    1.  
    2.  
    3. class myClass
    4. {
    5.     protected int myInt = 0;
    6.     public int MyInt
    7.     {
    8.         get{return myInt;}
    9.         set
    10.         {
    11.             myInt = value;
    12.         }
    13.     }
    14. }
    15.  
    16.  
    Then I call this:
    Code (csharp):
    1.  
    2. HOTween.To(myClass, 1, new TweenParms().Prop("MyInt", 200).UpdateType(UpdateType.TimeScaleIndependentUpdate));
    3.  
    Will HOTween consider this variable public and find it? Because right now when I attempt something like this, HOTween doesn't seem to work.
     
  26. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @AbsurdHart: yes, it will work (HOTween can tween both public fields and public getters-setters). But maybe my example mislead you: the first parameter must be a reference to the instance of the class containing the property/field, not to the class itself
    Code (csharp):
    1.  
    2. // This is a sample MyClass instance
    3. MyClass myClassInstance = new MyClass();
    4. // And thus:
    5. HOTween.To(myClassInstance, 1, new TweenParms().Prop("MyInt", 200).UpdateType(UpdateType.TimeScaleIndependentUpdate));
    6.  
     
  27. Hidden

    Hidden

    Joined:
    Apr 4, 2011
    Posts:
    20
    I have an error that's stopping me from building on iOS;

    ArgumentOutOfRangeException: Argument is out of range.
    Parameter name: index
    System.Collections.Generic.List`1[Holoville.HOTween.Core.ABSTweenComponent].get_Item (Int32 index)
    Holoville.HOTween.HOTween.DoUpdate (UpdateType p_updateType, Single p_elapsed)
    Holoville.HOTween.HOTween.Update ()

    Any thoughts what I'm doing to cause this and how to fix it?
     
  28. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Hidden: this is a very strange error. Could you post your tween code (or send me a package with a sample project) so I can replicate the error, and see what's going on?
     
  29. Hidden

    Hidden

    Joined:
    Apr 4, 2011
    Posts:
    20
    its hard to know exactly what line is causing it but i think its somewhere in

    Code (csharp):
    1. public static void PanelDisappearTo(GameObject panel, AnimationDirection direction, Vector3 originalPosition, int ID)
    2.     {
    3.         HOTween.Complete(ID);
    4.         FadeWidgetsRecursively(panel, transitionTime-0.01f, 0f, 0f, ID);
    5.         FadeWidgetsRecursively(panel, 0.01f, transitionTime+0.01f, 0f, ID);
    6.        
    7.         Collider[] colliders = panel.GetComponentsInChildren<Collider>();
    8.        
    9.         foreach(Collider coll in colliders)
    10.         {
    11.             coll.enabled = false;
    12.         }
    13.        
    14.         Vector3 transitionOffset = Vector3.zero;
    15.        
    16.         switch(direction)
    17.         {
    18.         case AnimationDirection.Left:
    19.             transitionOffset = Vector3.left * transitionPixel;
    20.             break;
    21.         case AnimationDirection.Right:
    22.             transitionOffset = Vector3.right * transitionPixel;
    23.             break;
    24.         case AnimationDirection.Up:
    25.             transitionOffset = Vector3.up * transitionPixel;
    26.             break;
    27.         case AnimationDirection.Down:
    28.             transitionOffset = Vector3.down * transitionPixel;
    29.             break;
    30.         case AnimationDirection.None:
    31.             transitionOffset = Vector3.zero;
    32.             break;
    33.         }
    34.        
    35.         Vector3 EndPosition = new Vector3(panel.transform.localPosition.x+transitionOffset.x, panel.transform.localPosition.y+transitionOffset.y, panel.transform.localPosition.z+transitionOffset.z);
    36.  
    37.         HOTween.To(panel.transform, transitionTime+0.1f, new TweenParms().Prop("localPosition", EndPosition).Ease(EaseType.EaseInOutSine).IntId(ID));
    38.         HOTween.To(panel.transform, 0f, new TweenParms().Prop("localPosition", originalPosition).Ease(EaseType.Linear).Delay(transitionTime+0.1f).IntId(ID));
    39.     }  
    or

    Code (csharp):
    1. public static void FadeWidgetsRecursively(GameObject obj, float duration, float delay, float alpha, int ID)
    2.     {
    3.         //Utilities.RemoveTweenColor(obj);
    4.        
    5.         UIWidget uiw = obj.GetComponent<UIWidget>();
    6.         Color alphaColor = new Color(1, 1, 1, alpha);
    7.        
    8.         if (uiw!=null)
    9.         {
    10.             if (uiw!=null)
    11.             {
    12.                 if (duration>0)
    13.                 {
    14.                     HOTween.To(uiw, duration, new TweenParms().Prop("color", uiw.originalColor * alphaColor).Delay(delay).IntId(ID));
    15.                     //TweenColor.Begin(obj, duration, uiw.originalColor * alphaColor);
    16.                 }
    17.                 else
    18.                 {
    19.                     uiw.color = uiw.originalColor * alphaColor;
    20.                 }
    21.             }
    22.         }
    23.        
    24.         uiw = null;
    25.        
    26.         foreach (Transform child in obj.transform)
    27.         {
    28.             Utilities.RemoveTweenColor(child.gameObject);
    29.            
    30.             if (child.collider!=null) child.collider.enabled = alpha == 0f ? false: true;
    31.            
    32.             uiw = child.gameObject.GetComponent<UIWidget>();
    33.            
    34.             if (uiw!=null)
    35.             {
    36.                 if (duration>0)
    37.                 {
    38.                     //TweenColor.Begin(child.gameObject, duration, uiw.originalColor * alphaColor);//TODO
    39.                     HOTween.To(uiw, duration, new TweenParms().Prop("color", uiw.originalColor * alphaColor).Delay(delay).IntId(ID));
    40.                 }
    41.                 else
    42.                 {
    43.                     uiw.color=uiw.originalColor * alphaColor;
    44.                 }
    45.             }
    46.            
    47.             uiw = null;
    48.            
    49.             FadeWidgetsRecursively(child.gameObject, duration, delay, alpha, ID);
    50.         }
    51.     }
     
  30. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    I have to go now, but I'll check it when I'm back. In the meantime, maybe you're animating something that gets destroyed while it's still animating? If that's the case, you should call one of HOTween's kill methods to clear any tween before destroying its target.
     
  31. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    Izitmme, I appreciate your timeliness. I am indeed using an instance of a class for the parameter, but I seem to keep getting this error:

    InvalidCastException: Cannot cast from source type to destination type.
    Holoville.HOTween.Plugins.Core.ABSTweenPlugin.SetValue (System.Object p_value)
    Holoville.HOTween.Plugins.PlugInt.DoUpdate (Single p_totElapsed)
    Holoville.HOTween.Plugins.Core.ABSTweenPlugin.Update (Single p_totElapsed)
    Holoville.HOTween.Tweener.Update (Single p_shortElapsed, Boolean p_forceUpdate, Boolean p_isStartupIteration)
    Holoville.HOTween.Core.ABSTweenComponent.Update (Single p_elapsed)
    Holoville.HOTween.HOTween.DoUpdate (UpdateType p_updateType, Single p_elapsed)
    Holoville.HOTween.HOTween+<TimeScaleIndependentUpdate>d__0.MoveNext ()
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    Holoville.HOTween.<StartCoroutines_StartTimeScaleIndependentUpdate>d__3:MoveNext()


    Here's a sample of my code:
    Code (csharp):
    1.  
    2.  
    3.        
    4.         int score = 6000;
    5.                 //scoreText is an instance of a class that has the public Get/Set variable
    6.                 //public int CurrentScore  
    7.  
    8.         HOTween.To(scoreText, 1, new TweenParms().Prop("CurrentScore", score).UpdateType(UpdateType.TimeScaleIndependentUpdate));
    9.  
    10.  
     
  32. Hidden

    Hidden

    Joined:
    Apr 4, 2011
    Posts:
    20
    Yeah it seems I was Destroying an object without using a kill function, but it's very hard to track down where these are occuring! is it to do with me using the HOTween.Complete()?
     
  33. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hey AbsurdHart,

    I replicated your code, and everything works perfectly. Can you check if you're using an old version of HOTween? There was an issue with ints that was fixed a while ago. To see your HOTween version, you can simply call
    Code (csharp):
    1.  
    2. // Latest version is currently 1.1.005
    3. Debug.Log("HOTween v" + HOTween.VERSION);
    4.  
    Here is a sample package that shows how I implemented your code.
     
  34. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hey Hidden,

    it actually has to do with any HOTween method (be it an Update or a direct call like Complete). Destroying objects should always be treated carefully, and you have to clear everything that might reference them (not simply related to HOTween - for example: event listeners need to be directly cleared too).

    The easy best-practice way - for HOTween - is:
    - If you are directly destroying an object, clear any HOTween from it using some Kill method.
    - When you are loading a new scene, just destroy all eventually running tweens with a simple call to HOTween.Kill();
     
  35. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    hi izitmee,
    your framework look awesome, but i failed to install it, i put the hotween in the unity asset folder, import the hotween editor package, save my project, restart, and i the hotween still didnt show up in the window unity toolbar
    i use unity 3.5.

    do i miss something?

    regards
     
  36. hima

    hima

    Joined:
    Oct 1, 2010
    Posts:
    183
    If you're using HOTween and not the visual editor, nothing will be shown in the toolbar. You have to call it from scripts.
     
  37. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Thanks himatako :)

    toto2003, you can get the Visual Editor (HOTween Editor) here
     
  38. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    Thanks for your patience and help. Yeah, the HoTween was just out of date. It works now. :)
     
  39. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
  40. yavadoo

    yavadoo

    Joined:
    Mar 24, 2012
    Posts:
    102
    Hi Izitmee,

    Maybe there is a solution for this already in this long thread. If so, excuses in advance.

    I am using Hotween for moving a vehicle along a path. This vehicle stops at the end of the path. If the player push a button the vehicle moves on the next path. The last point of the first path is the first point of the next path. Means the vehicle should start exactly where it stopped before. But the vehicle is moving always a bit back.
    The Hotween gizmos is showing this "spike back" also.

    In the screenshot you see the gizmo of the last point of the old path and the first point of the new path (just simple transforms).

    I could probably use on large path for all single paths and just stop or pause hotween at certain positions. But then I dont have the smooth stops of the ease functions or is there a way for a smooth stop using Pause()?

    Thanks in advance for reading.

    Here the code I use:
    Code (csharp):
    1.  
    2. PlugVector3Path pvp = new PlugVector3Path( pathsVector[pathCounter] );
    3.    
    4. HOTween.To( transform, speed, new TweenParms().Prop( "position",pvp ).Ease( EaseType.EaseInOutSine ).UpdateType(UpdateType.Update));
    $screen.jpg
     
  41. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hey yavadoo :)

    I tried to reproduce your issue, but without success. When more than one path is connected (with identical end/start position) they work perfectly here. Could you check that you have the latest version (1.1.005 - just call Debug.Log(HOTween.VERSION) to get it) and send me a non-working example so I can see what's wrong?

    This is the code I used to test it (path0 ending point is identical to path1 start point, and I didn't assign UpdateType.Update simply because it's the default type of update):
    Code (csharp):
    1.  
    2. void StartTween()
    3. {
    4.    twObj0 = HOTween.To(
    5.       myTransform, 8, new TweenParms()
    6.       .Prop( "position", new PlugVector3Path( path0 ) )
    7.       .Ease( EaseType.EaseInOutSine )
    8.       .OnComplete( OnComplete )
    9.    );
    10. }
    11.  
    12. void OnComplete()
    13. {
    14.    Debug.Log( "Complete - start second path tween" );
    15.    // New tween on connected path
    16.    twObj0 = HOTween.To(
    17.       myTransform, 8, new TweenParms()
    18.       .Prop( "position", new PlugVector3Path( path1 ) )
    19.       .Ease( EaseType.EaseInOutSine )
    20.    );
    21. }
    22.  
     
  42. yavadoo

    yavadoo

    Joined:
    Mar 24, 2012
    Posts:
    102
    Sorry that I have always these strange issues :)
    I extracted the relevant parts of my project (so its a bit messy now) but it shows the problem. In the hierarchy view you find a Gameobject named Hotween. If you move that to 0,0,0 it works fine but not on any other position. Maybe the error is on my side but I really can not find it.
    I updated the Hotween today 1.1.005

    Thank you

    PS. Can not upload the project here (dunno why). I send it to you by mail (still have your address)
     
  43. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    New release: HOTween v1.1.006

    - Fixed PlugVector3Path bug (determining if starting position was identical to first waypoint could give incorrect results, due to floating point imprecision).

    As usual, latest version can be grabbed from HOTween's website

    Hey yavadoo, sorry: it was totally my fault, and thanks for catching it :) Due to the above bug, comparing if the starting point was identical to the first waypoint wasn't precise (in some cases, which still had never occurred to me :p). Thus HOTween was adding an additional waypoint used to reach the starting one - and since those two waypoint were so near a "huge" additional curve was created.
    The latest version fixes it.
    P.S. you don't need to add "HOTween.showPathGizmos = true;" inside OnDrawGizmos (unless you really want to ;)): you just need to write it once, wherever you want.
     
    Last edited: Jun 15, 2012
  44. yavadoo

    yavadoo

    Joined:
    Mar 24, 2012
    Posts:
    102
    Thanks again for the fast Bugfix. On most payed software you have to wait much longer :)
     
  45. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    That's why I hate most payed softwares ;D (disclaimer: I'm not referring to other Unity plugins, but to those big bulky softwares that have buglists older than 2 years - arargh! :p)
     
  46. MaDDoX

    MaDDoX

    Joined:
    Nov 10, 2009
    Posts:
    764
    Hi Izitmee. Like I told you we've migrated our under-production game from iTween to HOTween with astounding performance gains. Although we could easily make things work using standard scripting, we really want to use the visual editor to create the tweens, primarily because we're going to include the full game, with code, in RageTools Pro, and we want to create a video tutorial showing the creation of the tweens visually - which's obviously much more artist-friendly with the visual editor.

    That's where we found some problems. After some investigation, we think we know what's happening. Since you can only reference editor-created tweens through their id, whenever we clone (if it's a prototype) or instantiate (if it's a prefab) the gameobject it refers to the same "entry" in the HOTween manager - therefore it doesn't specifically refer to that instance, but to *all* instances. Which's definitely not what we need. For instance, we want many objects following a certain path, but each of them is at their own time, and when we reset the animation we should only reset that instance that finished the tween - not the ones under way :)

    So, I've talked to Sandro about it and (supposing there's no other way to do this that we're unaware of) that's his suggestion: Having a "HOTweenInstance" script, attachable to any game objects, that basically holds its own HOTween Parameters - just the data, not even a monobehavior needed. This way we could have a simple script attached to the game object that, once run, would send a play command to the manager passing the ID (as defined in the visual editor) plus the game object reference as a key. This way the manager would play the animation with that ID but only in one specific object.

    Other cool options would be being able to play that ID animation in all the children of the key gameobject, and all tweens in the key gameobject - in both cases after they're added to the manager, of course.

    What do you say, unneeded, crazy or maybe? :)

    PS.: We clone pre-instantiated disabled game objects ("prototypes") instead of using prefabs due to its many advantages - like keeping instantiated references without having to use "Find" commands.
     
    Last edited: Jun 20, 2012
  47. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Crazy!!! :D Ahaha, no, seriously, this looks like an interesting puzzle, but I'm not sure I got it. I'm going to bed now (midnight here), but if you could send me an example package of what you're trying to attempt, tomorrow morning I'll look into it and see what can be done.
     
  48. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    good night ;)
     
  49. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Thank you! And good morning ;)

    @MaDDoX: I thought a little more about what you said. I'm still not sure if I understood correctly what you're trying to do, but I think this might already help: you can also use HOTween static methods with a "target" parameter (btw, here is the complete list of parameters you can pass to those static methods). So, if for example you created a tween for the position property of a transform, you could access it like this, instead than using the ID: HOTween.DoSomething(myTransformInstance)
    Code (csharp):
    1.  
    2. // Rewind example:
    3. HOTween.Rewind(myTransformInstance);
    4.  
    Let me know if I'm on the right track.
     
    Last edited: Jun 21, 2012
  50. MaDDoX

    MaDDoX

    Joined:
    Nov 10, 2009
    Posts:
    764
    Let me try to explain it better. In the visual editor you can only have an animation associated to an instance. When you clone an object, there's no entry for the cloned object in the manager. What's the use of passing it as a parameter then? Nothing would happen.. :( That's why Sandro proposed an optional component, to be attached to the desired "clonable" game object or prefab which, as soon as it awakes, auto-registers itself to the manager. This "HOTweenInstance" dude would hold all the animation data needed, although the tweening itself is processed by the manager. In this case commands like "play" would get an overload with two parameters - ID and instance. Something like:
    Code (csharp):
    1. HOTween.Rewind(ID, myTransformInstance);
    That would make the visual editor animations (which can only be referenced through an ID) usable for multiple instances spawned at different times, without interfering with each other - which's our final goal.

    Sorry if it still sounds confusing, I'm afraid I can't make it more clear with text only. Sandro will try to assemble a demo scene showing the problem/limitation today, I'm traveling to my hometown later tonight so I won't have the time, but if he sends me something I'll forward it your way. Cheers!