Search Unity

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,242
    Hey @Dynablaster . I would recommend, as usual, @Baroni's Simple Waypoint System, which implements HOTween (and soon DOTween) and has a lot of features ;) Check it out but I'm pretty sure it can do what you ask.
     
  2. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    @Izitmee thanks, as usual :D
    @Dynablaster for a similar implementation see this post (might or might not need Simple Waypoint System, but the path management should be of help to you)
     
  3. Dynablaster

    Dynablaster

    Joined:
    Feb 28, 2014
    Posts:
    9
    @Izitmee @Baroni Thank you both for the quick reply. @Baroni What did you mean I may or may not need SWS; I scrolled through the posts on the link you gave and maybe I am missing something? Anyway I think I will buy SWS because it does seem like it would solve all my problems for a reasonable price.
     
  4. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    @Dynablaster
    Getting the current tween position via tween.GetPointOnPath is a method in HOTween itself, not SWS. You can use it in SWS too, of course, but I thought that the extra benefit is actually how SWS handles paths.
     
  5. Dynablaster

    Dynablaster

    Joined:
    Feb 28, 2014
    Posts:
    9
    @Baroni
    Oh that, yeah I saw that but still as you have said with SWS you can switch paths right? Neither HOTween or iTween can switch paths(iTween can but not in the way I want it to). Actually now I think I have underestimated the complexity of what I I want to do... The 3 paths/lanes won't be the same length so switching between them may be little tricky. I need to switch between two adjacent paths at points that are on the cross section of the paths. I am having hard time explaining this... You know how infinite runners work... So can SWS do this?
     
  6. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    @Dynablaster
    Well, you could insert a waypoint at the desired position anywhere on the new path and let your object start from there. (Let's discuss further things about SWS in its own thread to not bother Izitmee with email notifications)
     
  7. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
  8. Jason18

    Jason18

    Joined:
    Nov 29, 2014
    Posts:
    2
    Hi,everyone. I use HOpath to test.When I build to "x86".There have some errors.How can I fix it? Thanks.
    Assets/Holoville/HOPath/PathPreview.cs(2,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
     
  9. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Hiya! I have no hands in HOPath so I wouldn't know, but that means there's a UnityEditor code somewhere that you should remove (start by removing "using UnityEditor" from the top of the involved class and then clean any error that might appear).
     
  10. Hiepvn

    Hiepvn

    Joined:
    Dec 1, 2014
    Posts:
    2
    Hi everyone. I use HOTween to tween a long value (Int64) but i get this error:
    Code (CSharp):
    1. InvalidCastException: Cannot cast from source type to destination type.Member.Set (System.Object , System.Object )
    2. FastDynamicMemberAccessor.MemberAccessor.Set (System.Object target, System.Object value) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Core/FastDynamicMemberAccessor/MemberAccessor.cs:173)
    My code is very simple:
    Code (CSharp):
    1. public long longValue
    2. {
    3.     get { return _longValue; }
    4.     set
    5.     {
    6.         _longValue = value;
    7.         Debug.Log(_longValue);
    8.     }
    9. }
    10. private long _longValue;
    11.  
    12. void Test()
    13. {
    14.     HOTween.To(this, 0.3f, new TweenParms().
    15.         Prop("longValue", (long)1000)
    16.     );
    17. }
    Do you have any ideas?
     
    Last edited: Dec 1, 2014
  11. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @Hiepvn Woops that's because HOTween can't tween Int64 values. I'd suggest moving to DOTween, where I can add an Int64 tween much more easily. Let me know if you can do that and I'll add it, otherwise I'll take care of this within HOTween.
     
  12. boolean01

    boolean01

    Joined:
    Nov 16, 2013
    Posts:
    92
    Hi there

    I installed HoTween and I am using the Visual Editor. I have a tween that on complete, is using the SendMessage action. Whenever I try and run it though (ie. as soon as the unity scene starts) I get the following error:

    Code (CSharp):
    1. MissingReferenceException: The object of type 'HOTweenManager' has been destroyed but you are still trying to access it.
    I found that the first thing that HOTweenManager.cs calls is DoDestroy(), so if I comment that out and don't destroy the manager, the send message works fine. However, I figure there is an important reason why the manager is calling that method :D

    Am I just missing a step when setting this up? Is this a bug? Is it safe to comment out DoDestroy()?

    Thanks!
     
  13. OceanBlue

    OceanBlue

    Joined:
    May 2, 2013
    Posts:
    251
    Hi, I would've thought this was easy (like it is with iTween) but doesn't appear to be.....
    How do I stop a looping tween???
    I need to be able to stop it (and the end of a loop), then be able to restart it at a later date.
    There is another tween in the scene that i DON'T want to get interrupted, so a stop all style command isn't an option.
    Help! I don't want to have to go back to iTween.
     
  14. Hiepvn

    Hiepvn

    Joined:
    Dec 1, 2014
    Posts:
    2
    @Izitmee:
    Thanks for reply!
    Because i'm using HOTween for a large project, so I will try DOTween on next project :)
    So, the problem with int64 in HOTween, i try to tween by a mediate float variable. Tween a float variable from 0 to 1 and use this float variable to set the target int64 variable. Although a bit complicated, but it can be used.
     
  15. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @boolean01 Ooops sorry that was a bug indeed! I fixed it and while waiting for the Asset Store version to be uploaded you can get v1.1.280 here :)

    @OceanBlue you can stop a tween by calling myTween.Pause(). Or if you simply want a tween to end each time loop ends, don't create loops. Instead simply set AutoKill to false and when you want to replay it you call myTween.Restart.

    @Hiepvn glad you found a solution ;)
     
  16. exitsimulation

    exitsimulation

    Joined:
    Feb 10, 2014
    Posts:
    82
    First of all: Thanks for your awesome plugin! (And also thanks for HoPath!)

    I want to use HOTween with HOPath to move a camera along a bezier curve between certain waypoints. I want the camera to stop at each waypoint with the option to go to the next or previous waypoint (always along the curve, not on a straight line). How can I achieve this with HOTween? I tried to mess around with GetPointOnPath but don't seem to fully understand it.
    Could you please lead me to the right methods?

    tl;dr Want to move back and forth between certain waypoints on a bezier curve
     
  17. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Hi @mongon, glad you like it (HOPath is all thanks to @Vevusio) :) For complex path stuff, I always suggest @Baroni's Simple Waypoint System, which implements stuff like you mentioned and HOTween in the background.
     
  18. exitsimulation

    exitsimulation

    Joined:
    Feb 10, 2014
    Posts:
    82
    Thanks for your fast response. Unfortunately I have to rely on an earlier version of Unity3D (4.0.1) which is not supported by SWS. I already asked Baroni If he could supply me with an earlier version of SWS (after I bought his plugin of course) but it seems impossible to him.
    Could you please lead me in the right direction with HOTween only.

    Edit: I think I can use UsePartialPath()

    Edit2: Seems to work partially (haha pun intented) but how can I play from waypoint 2 to 1 (backwards)? I tried both UsePartialPath(2,1) and UsePartialPath(1,2).Reverse() with both no success. Is it possible to move along a path backwards?
     
    Last edited: Dec 11, 2014
  19. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    That should work. Did you try UsePartialPath and then PlayBackwards instead than Reverse? Let me know, because I implemented those methods for SWS and never used them myself, so honestly my memory is messing me up.
     
  20. exitsimulation

    exitsimulation

    Joined:
    Feb 10, 2014
    Posts:
    82
    Code (CSharp):
    1.  
    2. HOTween.To(CubeTrans1, 4, new TweenParms()
    3. .Prop( "position", path1.OrientToPath())
    4. .Loops (-1,LoopType.Yoyo)
    5. .Ease(animCurve)).PlayBackwards();
    This does not work at all. The tween does not move. Neither with .Reverse() at the end. :( Any hints?
     
  21. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @monogon Imagine a tween like a YouTube video. PlayBackwards plays the video backwards from the point it currently is until it's completely rewinded. Which means that if you have a tween with a 10 seconds duration and you play it for 4 seconds then call PlayBackwards it will play backwards from 4 to 0. If instead you call PlayBackwards as soon as you create the tween, meaning the current time is 0, the tween will set itself in reverse mode but will do nothing since it's already rewinded :p
     
  22. exitsimulation

    exitsimulation

    Joined:
    Feb 10, 2014
    Posts:
    82
    Ok thanks!
    But how can I apply all the methods I need? Currently It is only accepting one of my needed paramters.

    I would need something like:
    Edit:
    Ok, I think I got it now. :)

    Code (CSharp):
    1.  
    2. Tweener theTween = null;
    3.            
    4. theTween = HOTween.To(transform, 4, new TweenParms()
    5.             .Prop( "position", path1.LookAt(artifact.position))
    6.             .Ease(animCurve)
    7.             .IntId(1)
    8.             .Pause(true)
    9.             .AutoKill(false)
    10.             .OnComplete(sendNewRotation));
    11.      
    12.         theTween.UsePartialPath(0,2);
    13.         theTween.GoTo(4f);
    14.         theTween.PlayBackwards();
     
    Last edited: Dec 11, 2014
  23. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @monogon Great! :) Instead of GoTo(4f) you can also do
    Code (csharp):
    1. theTween.Complete();
     
    exitsimulation likes this.
  24. omatase

    omatase

    Joined:
    Jul 31, 2014
    Posts:
    159
    Been using HOTween for a few months now and I really like the power it provides in its scripting API. One thing I haven't ever tried to do and haven't seen information on how to do is how to use the .To() method to script a private variable that is an int. I have a private variable in my MonoBehaviour declared like this:

    Code (CSharp):
    1. private int _valueToDisplay = 0;
    I want to tween that variable to a new value but I don't know how to give the To() method a variable and have it tween that variable and not a property on an instance of that variable. I'm sure if I made the member variable public I could pass "this" as the target and then "_valueToDisplay" in the Prop() function on the TweenParams class but if it's possible to do it without that I'd like to.

    Here's how I have it right now. I'm sure it will fail though since "_valueToDisplay" is private.

    Code (CSharp):
    1. HOTween.To(this, .5f, new TweenParms().Ease(EaseType.EaseOutExpo).AutoKill(true).Prop("_valueToDisplay", value)).Play();
     
  25. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Glad you're enjoying the API :) Though sorry but HOTween only works with public variables.
     
  26. omatase

    omatase

    Joined:
    Jul 31, 2014
    Posts:
    159
    OK sounds good. I have switched them to public variables. That will be fine. By the by, when will DOTween be out of Alpha and Beta? I'm really excited about the increase in performance but I don't want to use it while it's in Alpha or Beta.
     
  27. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    I am kind of enjoying the alpha/beta of DOTween, but I should really put it out of it. Will try to do it this week :)
     
  28. amrakdab

    amrakdab

    Joined:
    May 23, 2013
    Posts:
    13
    I think this is more a Unity question, but it's kind of hotween related. I have created a sequence and applied it to some objects. When the tween finishes, the objects just randomly spiral out of control. I was expecting them to sit stationery as they do before the tween is run. Any ideas?
     
  29. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @amrakdab Hi :) If the tween is finished it's certainly not a HOTween issue. I imagine you must have other forces acting on those objects (maybe physics?) which are just lurking in the shadows waiting to take control as soon as HOTween leaves.
     
  30. Cizfroz

    Cizfroz

    Joined:
    Jan 1, 2015
    Posts:
    8
    Hi, dev.. I'm new in this forum and have 2 questions. Is this asset free for commercial use? Is this asset ready for windows phone 8 build? Thank you...
     
  31. amrakdab

    amrakdab

    Joined:
    May 23, 2013
    Posts:
    13
    Yeah, I think you are spot on. I have done some further testing and noticed, when the tweened objects don't hit anything during the tween, they sit in place. When they do hit 1 or more things, it looks like the physics that would have happened all occur when the tween is complete.

    I'm learning on the fly here, maybe if I disable the rigidbody during the tween and then enable it again afterwards?
     
  32. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @amrakdab I am not sure about the best way, but I would first try to set the kinematic flag to TRUE while tweening, and re-enable it later.

    @Cizfroz yes and yes :)
     
  33. amrakdab

    amrakdab

    Joined:
    May 23, 2013
    Posts:
    13
    I ended up removing the rigidbody component completely as it's not necessary any longer. I have come up with another question though.

    I am tweening along a path and am using orienttopath to have my object rotate in the direction of the path which works great.

    However, over the last 20% of the path tween, I would like to take over the rotation of my object as it effectively lands on the ground.

    I tried using a sequence, but this looks a bit clunky and loses the nice curve the object is following on the first path.

    Any suggestions on this one?
     
  34. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    You could use a trick to keep the tween as a single element. Add an OnUpdate callback, and when you know you're done with the first 80% use it to update the rotation manually. HOTween will still change the rotation every frame, but since OnUpdate is called AFTER the changes happen, if you override it the rotation you set will be the final one.
     
  35. ZeroDivide

    ZeroDivide

    Joined:
    Oct 10, 2013
    Posts:
    2
  36. NeophyteGamer

    NeophyteGamer

    Joined:
    Aug 26, 2013
    Posts:
    38
    Hey Izitmee,

    I was wondering if it is possible to create an object and have it start at a position of another object's tween then just follow the speedbased tween from there?

    In case that wasn't clear, I am using your tween engine for creep path on a Tower Defense game. I want a sort of carrier creep that when that dies it spawns a bunch of other creeps from where it died. Then those spawned creeps will follow rest of the predetermined path. And if it matters, have it loop like it started from the beginning.

    Thanks!
     
  37. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Hi @NeophyteGamer . You could grab the time position of the previous tween (myTween.position) and then after creating the creep tween you can use Goto(prevTweenPosition) to send it at that exact time position. Since they're using the same path it will jump to the same spacial position as the other one.
     
  38. -RaganorK-

    -RaganorK-

    Joined:
    May 9, 2014
    Posts:
    14
    Hi @Izitmee, first thank you for this amazing plug-in. Its so simple that i made it my first and only choice for tween to all my upcoming games. and replaced it with my current project too. Your creation was that awesome.

    Though I am using it for some time now, I now want to take out more juice from the plug in. Can you help me with that ? I want to rotate an object, slowly from start then get faster, then it rotates for sometime at a constant speed and then slow down to zero.

    Also, can you please provide examples with the documentation of the plug in features. There are many things I see in the plug in but i dont know how to use it.

    Thank you once again for this awesome plug in.. Cheers..
     
  39. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Hi @-RaganorK-

    to rotate an object slowly then constant then slowly again you could create an AnimationCurve like this one and use it as an ease:

    easecurve.png

    About examples, there are a few here, but more if you download it from the Asset Store.

    But most of all, if you want to take out more juice from it, I'd suggest upgrading to DOTween :)
     
  40. Mr_Cad

    Mr_Cad

    Joined:
    Dec 7, 2013
    Posts:
    27
    I noticed whenever I call .Pause() .Kill() or HOTween.Kill(tweener)
    The tweener will still move for 1 frame then only fully stop. Is this a bug?
    I don't see this problem when I'm running it in Editor but it happens when I try to run it on mobile.

    This is how I create the tweener
    Code (CSharp):
    1. TweenParms parm = new TweenParms().Prop("localPosition", targetPos).Ease(EaseType.Linear).Loops(-1, LoopType.Yoyo);
    2. m_tweeners[i] = HOTween.To(m_upgradePointers[i].transform, m_upgradeBarDurations[i], parm);
    This is how I stop it
    Code (CSharp):
    1. m_tweeners[i].Pause();
    Tried DOTween but it behaves the same, it also feels like move 1 additional frame then only stop.


    I'm using the latest version of HOTween 1.3.035
     
    Last edited: Feb 6, 2015
  41. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Hi @Mr_Cad, and sorry for the slow reply. I'll get back on Wednesday and check this out, though it seems very weird that that might happen, since Pause immediately sets a toggle on the tween that prevents it to be updated further.
     
  42. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36
    in DoTween, i found "DoLocalPath" can let my NGUI's gameObject move in "localPosition"..
    can i use HoTween do the same thing ?? i only found "PlugVector3Path", but it's about "position" while not "localPosition"....
     
  43. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    In HOTween, the Prop string determines the property you want to animate. So to tween a localPosition you just write "localPosition" instead than "position" :)

    Code (csharp):
    1. HOTween.To(myTransform, 1, new TweenParms().Prop("localPosition",new PlugVector3Path(path,EaseType.easeInQuad,true).ClosePath()));
     
  44. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36
    very thanks for reply...
     
  45. hierro__

    hierro__

    Joined:
    Sep 22, 2014
    Posts:
    59
    Hi all, i stepped into something pretty curious, i'm using a seuquence composed by several tweens (all paused), then i insert this sequence into another sequence, at the end i play and everything works just fine.
    If i use Insertcallback in the first sequence, callback is never called, any hints ?

    Edit : I tried also appendCallback, no news.
     
    Last edited: Mar 30, 2015
  46. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Hey @hierro__,
    I tried to replicate your issue, but everything works here. Can you replicate it in a barebone project and send it to me, so I can check what's wrong?
     
  47. hierro__

    hierro__

    Joined:
    Sep 22, 2014
    Posts:
    59
    Hey thank you for reply, attached a simple package that replicates the issue.
    Basically seems like paused sequences don't call any callback function.
     

    Attached Files:

  48. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Grabbing and testing now (but maybe I'll interrupt for dinner)
     
  49. hierro__

    hierro__

    Joined:
    Sep 22, 2014
    Posts:
    59
    Sorry it was a uncomplete packaging, here u are, press "a" to test the call, thank you a lot.
     

    Attached Files:

  50. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @hierro__ Ah, got it. I misunderstood your first report, thinking that with "first sequence" you meant the parent one, my bad. Callbacks work only when added to main sequences, not to nested ones.

    (EDIT: no worries for the incomplete package, I managed ;))