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. MaDDoX

    MaDDoX

    Joined:
    Nov 10, 2009
    Posts:
    764
    Daniele, get over it.

    It's HOT tween. The masses agree with me, you're alone so just let it go kthxbye B)

    lol
     
  2. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Lol I know, you're right. Still, if that's how you want to play it, then it's Ray Gtools, you Free Cow!!! Ah!!! Revenge!!! :D
     
  3. nmax

    nmax

    Joined:
    Feb 13, 2010
    Posts:
    6
    Hi there,

    How can we use waypoints with HOtween?

    Thanks

    m@x
     
  4. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hi there :)

    You create a list of Vector3 points and assign them to HOTween. You can check and download the path basics example here.

    If instead you want a full visual system focused on waypoints, I'd suggest Baroni's Simple Waypoint System, which also uses HOTween.
     
  5. nmax

    nmax

    Joined:
    Feb 13, 2010
    Posts:
    6
    Thanks :)
     
  6. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @absameen: got a question about the best implementation and usability. Since the AnimationCurve would only be used for easing and not to determine the duration of the tween, do you think I should A) ignore the length of the curve, and just consider 0-1 the min/max values, or B) actually adapt the easing to the full length of the curve? It's just a usability issue after all, but A would be slightly more performant, while B would be more usable.
     
  7. MaDDoX

    MaDDoX

    Joined:
    Nov 10, 2009
    Posts:
    764
    Free Cows are cool, milk for everyone! :D

    HOT tweens are also cool. Wait.. they're hot.. I mean... *~* #confused
     
  8. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    New SUPERCOOL* HOTween update: v1.1.600

    - Unity AnimationCurves can now be assigned to easing (instead than the regular ease curves)

    I love this new feature, thanks to absameen for requesting it. Now, wherever you would have assigned an EaseType (Tweeners or TweenPlugins), you have the option to assign a Unity AnimationCurve instead, to use for easing. You can assign an hyperlong curve or a supershort one: it will be automatically stretched by HOTween in order to consider the last key as the correct end of the easing.

    As usual, latest version is on HOTween's website, and in a couple days on the Asset Store.

    HOTween Visual Editor will implement them soon :)

    * Really! ;)
     
  9. shaderbytes

    shaderbytes

    Joined:
    Nov 11, 2010
    Posts:
    900
    super amazing feature addition ! thanks
     
  10. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Thanks a lot shaderbytes, I like this feature a lot :)

    And now! For some cross-promotion (if I may)!!!

    I just released a new plugin (my first non-free one) on the Asset Store: HOTools. It's a utility panel with various commands and collections that I find super-useful for my workflow.
    Here is the documentation and features, and here the Asset Store link.

    End of cross-promotion ;)
     
  11. absameen

    absameen

    Joined:
    Oct 5, 2011
    Posts:
    121
    Great update, thanks for the addition!
     
  12. Nicolas-Delbaer

    Nicolas-Delbaer

    Joined:
    Nov 19, 2012
    Posts:
    6
    Hi everyone,

    First, your tween engine is really awesome, thank you for this great job :)

    Now here is my question: I was wondering. Is it possible to use tweens or sequences like a kind of timer ?
    I have to use a "illuminate" function from a GameObject component in sequence every "t" time.
    The sequence consist to illuminate boxes in rythm (with an easer and a duration).

    Example:

    Wait t seconds.
    OnStepComplete: { DesilluminateBox(i++); IlluminateBox(i); }


    Thanks in advance for your advices :)
     
  13. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,817
    Hi there,
    Still getting my head around Hotween and I was just wondering, How could I make an object spin several times using Hotween?
    If i put in something like this the object doesn't spin, im guessing because 360 and 0 can be thought of as the same, but how can i get it to wind up rotations?

    Code (csharp):
    1. HOTween.To(ExtraSpin.transform, .5, new TweenParms().Prop("localRotation", Vector3(0,0,360)).Ease(EaseType.EaseOutQuad));
    Also, is there a list of properties that can be tweened? I just guessed "localRotation" but what if you wanted to tween a variable that you have created in a script?

    Thanks
    Pete
     
  14. Nicolas-Delbaer

    Nicolas-Delbaer

    Joined:
    Nov 19, 2012
    Posts:
    6
    YourTween = HOTween.To(YourGO.transform, .5, "rotation", new Vector3(0,0,3600), true);

    The last parameter is the isRelative flag. This tween will spin 10times the GO.
     
  15. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @petey: exactly what Nicolas said. If you make a rotation non-relative, it will be converted to quaternions and use the nearest approach.

    About animating other stuff, you can animate anything you want, as long as it's public and not static. For example, if you want to animate a float property "someFloat" in an instance of a class "SomeClass", you could simply do:
    Code (csharp):
    1.  
    2. // This animates someFloat from its current value to 10
    3. HOTween.To(someClassInstance, 1, "someFloat", 10);
    4.  
     
  16. Nicolas-Delbaer

    Nicolas-Delbaer

    Joined:
    Nov 19, 2012
    Posts:
    6
    @Izitmee: Hi Izitmee, is it possible to use HOTween using those informations:

    Total duration: 5sec
    Number of steps: 4Steps
    Easer: Linear

    For each step I would like to add a callback (nothing complicated with the OnStepComplete(MyFunc)).

    I would like to launch this sequence in Loop -1 until I stop it.

    I am a bit confused cause there is not a classical property tween in this case.


    Thanks,
    Nicolas
     
  17. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hi Nicolas,

    I'm not sure what you mean with those steps? To do a loop with each step lasting 5 seconds, using a transform for example, you would simply do:
    Code (csharp):
    1.  
    2. HOTween.To(myTransform, 5, new TweenParms()
    3.    .Prop("position", new Vector3(1, 1, 1))
    4.    .Ease(EaseType.Linear)
    5.    .Loops(-1)
    6.    .OnStepComplete(myCallback)
    7. );
    8.  
    But I suppose that's not what you meant?
     
  18. Nicolas-Delbaer

    Nicolas-Delbaer

    Joined:
    Nov 19, 2012
    Posts:
    6
    Thanks, but not really :)

    The whole sequence have to last 5seconds launching at each step (with an amount of 4) a Callback regarding the easer.

    So, for a linear easer, I would like to trigger the callback each 1.25sec (5/4sec). Without animating any specific property.
     
  19. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Oh I see :)

    Ok, then you'll have to create a Sequence and add some callbacks to that. For example, this Sequence will run an infinite loop with a tween that will last 5 seconds, and that will throw a callback every 1.25"
    Code (csharp):
    1.  
    2. Sequence mySeq = new Sequence(new SequenceParms()
    3.   .Loops(-1)
    4.   .OnStepComplete(myCallbackFunction)
    5. );
    6. // Append regular tween
    7. mySeq.Append(HOTween.To(myTransform, 5, "position", new Vector3(1,1,1)));
    8. // Insert callbacks (I insert only 3, since the last one will rely on the
    9. // Sequence's onStepComplete callback)
    10. mySeq.InsertCallback(1.25f, myCallbackFunction);
    11. mySeq.InsertCallback(2.5f, myCallbackFunction);
    12. mySeq.InsertCallback(3.75f, myCallbackFunction);
    13. // Start the sequence (Sequences don't start automatically like Tweeners)
    14. mySeq.Play();
    15.  
     
  20. efreet

    efreet

    Joined:
    Sep 2, 2009
    Posts:
    34
    Hi Izitmee,
    In a sequence does a tweeners delay, loops and OnStepComplete get taken into account or is it overridden by the SequenceParms?

    Example:
    Code (csharp):
    1.         Sequence seq = new Sequence(new SequenceParms()
    2.             .Loops(1, LoopType.Yoyo));
    3.        
    4.         //This tweener when in a sequence does no delay, no loop and no callbacks
    5.         //When adding a dubplicate tweener to the sequence it then gives the callbacks, which makes me thing they come from SequenceParms.
    6.         //And the object doesn't move correctly like it does as a standalone tweener.
    7.         seq.Append(HOTween.To(transform,1, new TweenParms()
    8.             .Prop("position", new Vector3 (0,20,0),true)
    9.             .Delay(2)
    10.             .Loops(2, LoopType.Yoyo)
    11.             .Ease(EaseType.EaseInOutSine)
    12.             .OnStepComplete(StepComplete)
    13.             .OnComplete(Complete)));
    14.        
    15.         seq.Append(HOTween.To(transform,1, new TweenParms()
    16.             .Prop("position", new Vector3 (0,20,0),true)
    17.             .Delay(2)
    18.             .Loops(2, LoopType.Yoyo)
    19.             .Ease(EaseType.EaseInOutSine)
    20.             .OnStepComplete(StepComplete)
    21.             .OnComplete(Complete)));
    22.        
    23.         seq.Play();
     
  21. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hi efreet,

    I was actually undecided if I should completely overwrite nested tweens loops (and no, delays don't work) when adding them to a Sequence, but I decided to leave them in case someone wanted to create "strange" sequences. That said, a Sequence is a straightforward timeline, so:

    - delays are overwritten
    - the total duration of the Sequence is calculated without taking any nested Sequences/Tweeners loops into account. So if you add a single tweener to a sequence, the sequence will last the exact duration of a single loop of said tweener. If instead there are more tweens added, you will see part of them looping, until the Sequence restarts. Considering this, an OnStepComplete added to a nested tween is not reliable: better to append/insert callbacks directly to the Sequence, with mySequence.InsertCallback/mySequence.AppendCallback
     
  22. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,817
    Hi dudes,
    Thanks for the help.
    Hey I was wondering one more thing, if I create a tween like this -

    Code (csharp):
    1. HOTween.To(SpinObj.transform, 1, new TweenParms().Prop("localRotation",Vector3(0,0,SpinAmount),true).Ease(EaseType.EaseOutQuad));
    How can I check the state of that particluar tween? I just want to make sure it's completed before another one can start.
    Sorry, it's probably a pretty basic question but I'm just a little unsure as how to use the Read-Only Properties in this case and access the tween created in the script.

    Thanks!
    Pete
     
  23. efreet

    efreet

    Joined:
    Sep 2, 2009
    Posts:
    34
    Ok thanks, got my head around it
     
  24. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hi petey,

    the best way to check if a tween is complete would be to store a reference to the tween when you create it
    Code (csharp):
    1.  
    2. // C#
    3. Tweener myTween = HOTween.To...
    4. // JS
    5. var myTween:Tweener = HOTween.To...
    6.  
    and then check myTween.isComplete. If TRUE, the tween has played fully (all loops included).

    Otherwise, if you want to run 2 tweens one after the other, I'd recommend checking out Sequences: superuseful for stuff like that:
    Code (csharp):
    1.  
    2. // C#
    3. Sequence mySeq = new Sequence();
    4. // Append first tween
    5. mySeq.Append(HOTween.To...);
    6. // Append second tween
    7. mySeq.Append(HOTween.To...);
    8. // Start the sequence (they don't start automatically like Tweeners)
    9. mySeq.Play();
    10.  
     
  25. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,817
    hey Izitmee, thanks! That worked.

    Code (csharp):
    1. var SpinTween : Tweener;
    2. function SpinOut(Amount : float){
    3.     if(SpinTween != null  SpinTween.isComplete == false)return;//exit out if there's one in progress
    4.     SpinTween = HOTween.To(ExtraSpin.transform, 1, new TweenParms().Prop("localRotation", Vector3(0,0,Amount),true).Ease(EaseType.EaseOutQuad));
    5. }
     
  26. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
  27. MaDDoX

    MaDDoX

    Joined:
    Nov 10, 2009
    Posts:
    764
    Hey Daniele, now that I (partially) recovered from the tremendous crunch on these latest Rage releases, let's talk about what I've touched in HOTween and what I think it's missing and it's relatively simple to add. As usual, some of what I did (and will suggest) might not be what you want for the product, absolutely no ill feelings if you disagree :) I'm adding you to our private FTP list, so you can check this mini-branch and maybe take advantage of some of its minor code changes, mostly on the editor side.

    - Width formatting - I think I've mentioned that to you before, I've always strived to get the component inspectors fit comfortably the minimum possible width. Maybe it's my web designer side talking loud, I'm not sure, but I get absolutely turned off when I have to use a horizontal scroll bar. At the same time I like to place shorter (on width) elements side to side to avoid vertical scroll bars. To make my life harder, Unity's OnInspectorGUI isn't exactly friendly in that aspect. The only reliable way I found to stack elements horizontally and still prevent horizontal bars from showing up is to set all but one element in the same row to fixed width (using GUILayout.maxwidth). That's basically what I did in the HOTween editor, I think it looks good but you'll be the final judge ;)
    - Button graphics - I needed more horizontal compression like I said, so for some crowded rows it made sense to use icon buttons. I've noticed you use internal dll methods for your graphics buttons. I use the old-fashioned (yet reliable and easy to set up) 'resources' folder approach, and since I wouldn't recompile the dll or anything I didn't have another option anyways.
    - Special characters like the one you used for the duplicate buttons weren't working on my system, probably language charset difference. So I've changed some button text to regular characters and others into texture buttons.
    - On the usability side, AutoDestroy being on by default is a tremendous hassle. I can't count how much time I've wasted trying to figure out why things weren't working 'coz I forgot it on. I've set it to off by default.
    - Autoplay is only good for two things: quick tests and to make you waste a 'play' 'coz you forgot it enabled :). I've set it to off by default.

    Code (csharp):
    1. HOTweenManager.cs
    2.     public bool paused = true;
    3.     public bool autoKill = false;
    4.  
    5. HOTweenComponent.cs
    6.     public bool destroyAfterSetup = false;
    - The ID field is one of the most important ones when hooking up tween calls, yet it got a bit too "discrete" visually with the latest GUI change. I've changed the Id text field color so it highlights better, but for just created HOTweens it'd probably be good to also have some highlight in the field label itself, since there's no text yet in the field.

    Suggestions for the Visual editor:

    -> Now that Unity 4 got the much-needed copy/paste script functionality, we should have a 'Target' field. This one is kinda self-explanatory, you have a tween fully set up and you just want to copy it over to another element in the scene. Instead of retyping all values, you simply copy over the component and update the tween target field, and it would re-link the 'properties' to be tweened. I know that probably uses reflection in your code, so it might not be too easy, maybe properties that couldn't be found in the children hierarchy would simply get deleted. It would be even better if, when the field was empty, the current game object was used as the "root" of the linking process, which would be carried out on start. Would be perfect for prefabs and such.

    -> Add 'Reset on Complete' toggle. As you'll notice on the demo scenes which use RageButton, I've had to add a toggle just for that, which's a very common setting that sometimes you need enabled and some times you need disabled. Although it's handy to have the high level control (for 'play reverse' scenarios, which use the same tween) I think it would make sense to have a similar toggle right inside the HOTween visual editor, for tweens that you only play forward.

    Well, that's it basically. Comments? :)

    PS.: Other than this small room for improvement the system has been rock solid, I can't thank enough for your amazing efforts!
     

    Attached Files:

    Last edited: Nov 24, 2012
  28. Nicolas-Delbaer

    Nicolas-Delbaer

    Joined:
    Nov 19, 2012
    Posts:
    6
    Hi, Izitmee

    First thank you it works pretty well. But in my case I have to do some crappy stuff like following:
    Code (csharp):
    1.  
    2.         int itemsCount = 4;
    3.         float totalTime = 2.5F;
    4.         float stepTime = totalTime / itemsCount;
    5.  
    6.         Sequence mySeq = new Sequence(new SequenceParms().Loops(-1).OnStepComplete(delegate() {
    7.             AudioSource.PlayClipAtPoint(Item4_Sound, Camera.main.transform.position);
    8.         }));
    9.  
    10.         mySeq.Append(HOTween.To(Item1.transform, totalTime, "position", Item1.transform.position));
    11.         mySeq.InsertCallback(stepTime, delegate() {
    12.             AudioSource.PlayClipAtPoint(Item1_Sound, Camera.main.transform.position);
    13.         });
    14.  
    15.         // Start the sequence (Sequences don't start automatically like Tweeners)
    16.         mySeq.Play();
    17.  

    As you can see, the appended tween is useless and really used to set the global duration. There is no easer plugged BTW.
    So I was thinking about a better stuff:

    Set you global duration on the sequence itself, adding some easer on it.
    After that, maybe use a "InsertAutoCallback" with and id parameter and the callback function. (or just a AddAutoCallback, like an ordered list of callback).
    If you follow me you will have something like that:
    Code (csharp):
    1.  
    2. //Init the sequence
    3. AutoSequence mySeq = new AutoSequence(5, new AutoSequenceParms()
    4. .Ease(EaseType.easeOutQuad)
    5. .Loops(-1)
    6. .OnStepComplete(CallFunction4)
    7. );
    8.  
    9. //Add Callback
    10. mySeq.AddCallback(CallFunction1);
    11. mySeq.AddCallback(CallFunction2);
    12. mySeq.AddCallback(CallFunction3);
    13.  
    14. //Launch the sequence
    15. mySeq.Play();
    16.  

    Tell me what do you think about that ? ;)

    Nico
     
  29. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Breno: wow you recovered in full power! :) I have to say I agree with everything you say, final additions included, and I feel soo stupid for those symbols not showing up on your system. I'm superbusy in these days, but I'll look into all those mods as soon as I can, and implement your own icons :)

    @Nicolas: I'm sorry, but I still am not sure I got it fully. Let me ask some questions:
    - you just want to have some callbacks called after some given time in a sequence? If so, why not using a coroutine?
    - how would the callback be added in your sequence example? they seem like they just happen one after another without taking considering any tween/time?
     
  30. Nicolas-Delbaer

    Nicolas-Delbaer

    Joined:
    Nov 19, 2012
    Posts:
    6
    @Izitmee: Hum I recognize that I haven't tested yet the coroutines. I have to take a look at this.
    Regarding the Tweens, the idea is to set the tween and compute the good timing.
    In this case, you have a count of 3 callbacks; so with the total time(5sec) and the number of step (3), you get the t time for each steps.

    I am tired, so I hope you understand what is in my mind :)


    Edited:

    Oh I was wondering too... yeah so many questions :)
    There is Tween.To, Tween.From, why not a Tween.FromTo ?
    Cause now I have to reset the property everytime I want to launch the tween which accumulate values each play.
     
    Last edited: Nov 25, 2012
  31. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    I would not be very willing to add a Sequence that just manages callbacks and nothing else, since it would be kind of a waste of resources. Using a simple coroutine would be much more effective. For example, this reusable coroutine would take the total duration and an array of the callbacks to call within it (behaving so that one is called when the coroutine starts, and one when it ends):
    Code (csharp):
    1.  
    2. IEnumerator SomeCoroutine(float duration, Callback[] callbacks)
    3. {
    4.   int totCalls = callbacks.Length();
    5.   int numCall = 0;
    6.   float intervalBetweenCallbacks = duration / totCalls;
    7.   while (numCall <= totCalls) {
    8.     callbacks[numCall]();
    9.     ++numCall;
    10.     yield return new WaitForSeconds(intervalBetweenCallbacks);
    11.   }
    12. }
    13.  
    14. void SomeFunction()
    15. {
    16.   StartCoroutine(SomeCoroutine(5, callbacksArray);
    17. }
    18.  
    Hope I wrote it correctly, since I'm very tired too ;) Only con about coroutines: they work only within MonoBehaviours.
    Anyway, I will think if I can find a way to implement it efficiently within Sequences :)

    About Tween.FromTo, I really don't understand how that would work, sorry :D If you just want to relaunch a tween from the beginning, you could just use myTween.Restart() - though again, I suppose that's not what you mean.
     
  32. mrKaizen

    mrKaizen

    Joined:
    Feb 14, 2011
    Posts:
    139
    Hi Izitmee,
    first of all HOTween rulez! ^_^
    Second: I'm needing to change params of a tween on-the-fly, should I use "ResetAndChangeParms"?

    I need to move an GameObj to another in N seconds, the point is that the second one is moving - I was thinging to use "HOTween.To" but with the "ResetAndChangeParms" inside the update (something like dynamicProps example, in tweenmax - I'm sure you know what I'm talking about ). Is it the right way?

    Tks in advance. ;)
     
  33. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Ciao Alberto,
    grazie per il rulez! Ok ora torno all'inglese ;)

    Yes that should work, though I have to say that it would be a waste of resources. I know it might sound silly of me, but in such a specific case, I'd suggest not using a tween at all, but simply updating your GameObject's position within one of its MonoBehaviour's Update method.
     
  34. mrKaizen

    mrKaizen

    Joined:
    Feb 14, 2011
    Posts:
    139
    haha ok, I was thinking exactly the same thing. ^_^
    Tks for the super-super-super fast answering..

    btw, watch out, I know you -_-
    (I'm working with Tano :p, I told me about you )
     
    Last edited: Nov 30, 2012
  35. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hehe, nice conversation, guys =)
    And Izitmee, thanks a lot for adding the AnimationCurve support, used it recently and got full power of tweening engine and flexibility of custom easing in one box!
     
  36. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Agh! You know me??? Means as soon as I'm back to Rome I'll have to kill Tano, so my identity will stay a mystery. That said: pleasure to know you ^_^

    EDIT: aha, hey Dmitriy! :) Glad you liked it, and I have to admit I love the new AnimatioCurve thing too, don't know why I didn't implement it before

    P.S. next thing to come (already done but waiting some test): straight path animation
     
    Last edited: Nov 30, 2012
  37. AngryOrange

    AngryOrange

    Joined:
    Jan 30, 2012
    Posts:
    103
  38. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hi AngryOrange: answered :)
     
  39. AngryOrange

    AngryOrange

    Joined:
    Jan 30, 2012
    Posts:
    103
    Got it , thank you:)
     
  40. AngryOrange

    AngryOrange

    Joined:
    Jan 30, 2012
    Posts:
    103
    Hi Izitmee... One more thing I want to understand correctly... If I have for elements and I want to move them in four different places I have to create 4 new parms objects for them right ?
    I thought I can have one parm ( TweenParms parm = new TweenParms() ) and inside of this one parm I can call script to get random value for positions.
     
  41. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hi AngryOrange, actually no, it doesn't work like that (though that would be cool: another thing I want to add in HOTween V2). The parm you pass to a Prop method-parameter is in the end a Vector3 (in case of a Transform), which is created directly when you create the TweenParms. So you'd have to create different parms for each tween.

    A shortcut to that, in case you want to have the same parameters for many tweens, except the Prop one, is:
    Code (csharp):
    1.  
    2. // Create basic parm object common to all Tweeners
    3. TweenParms parms = new TweenParms().Loops(-1).Ease(EaseType.EaseOutBack);
    4. // Modify only the prop for each tween you create
    5. // (using NewProp instead than Prop, which overwrites previous Prop settings)
    6. HOTween.To(myTransform0, 1, parms.NewProp("position", myRandomPosition0));
    7. HOTween.To(myTransform1, 1, parms.NewProp("position", myRandomPosition1));
    8. HOTween.To(myTransform2, 1, parms.NewProp("position", myRandomPosition2));
    9.  
     
    Last edited: Dec 3, 2012
  42. Dgizusse

    Dgizusse

    Joined:
    Feb 1, 2012
    Posts:
    30
    Hi Izitmee,

    I'd like to know if there's a way to make the Delay of a tween to use the timeScale of the tween?

    Here's an example that shows that the timeScale doesn't change the delay duration.
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using Holoville.HOTween;
    5.  
    6. public class DelayTimeScale : MonoBehaviour {
    7.     Tweener t;
    8.     void Start () {
    9.         t = HOTween.To(transform, 1.0f, new TweenParms().Delay(5.0f).Prop("position", new Vector3(10.0f, 10.0f, 10.0f)).OnComplete(OnComplete));
    10.     }
    11.     void Update() {
    12.         if (t == null) return;
    13.        
    14.         if (Input.GetKey(KeyCode.Space)) {
    15.             t.timeScale = 2.0f;
    16.         } else {
    17.             t.timeScale = 1.0f;
    18.         }
    19.     }
    20.     private void OnComplete() {
    21.         Debug.Log(Time.timeSinceLevelLoad);
    22.     }
    23. }
    24.  
    Thanks!
     
  43. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hi Dgizusse,

    actually, the delay is not influenced by HOTween's timeScale on purpose (initially it was, but as some user made me notice it wasn't the "correct" behaviour). Though it should be influenced correctly by Unity's timeScale (unless you're using the TimeScaleIndependent UpdateType).
     
  44. Dgizusse

    Dgizusse

    Joined:
    Feb 1, 2012
    Posts:
    30
    Ok.
    Using the Unity TimeScale won't be an option for me. I'll implement my own delay.

    Thanks!
     
  45. Madgeniy

    Madgeniy

    Joined:
    Apr 21, 2012
    Posts:
    14
    I have the same issue if I use or not use autokilloncomplete property, I'm using the latest version of HOTween.
     
  46. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hi Madgeniy,

    not sure what's the issue you're having, in your case. If it's simply that you see that message, it's ok and not an error. It means you started a tween which is tweening a property that was already being tweened, and thus overwrites it.
     
  47. Bowie-Xu

    Bowie-Xu

    Joined:
    Sep 14, 2011
    Posts:
    28
    Hi All
    I changed iTween to HoTween yesterday and turns out HoTween is much powerful than iTween.
    But I get a NullReferenceException when I try to use Tweener.GetPointOnPath function.

    Here is my code:

    private Sequence _Sequence = null;
    private Tweener _tweener = null;
    private Vector[] path;

    _Sequence = new Sequence(new SequenceParms().Loops(-1, LoopType.Yoyo));
    _tweener = HOTween.To(gameObject.transform, _time, new TweenParms().Prop("localPosition",new PlugVector3Path(path,EaseType.Linear,false))
    .OnStart(OnPathMoveStart)
    .OnUpdate(OnPathMoveUpdate)
    .OnComplete(OnPathMoveEnd));
    _Sequence.Append(_tweener);
    _Sequence.Play();

    after tween started , I wrote some code in OnPathMoveUpdate function:

    void OnPathMoveUpdate()
    {

    if(_tweener != null)
    {
    float ratio = _tweener.elapsed/_tweener.duration;
    Vector3 nextpos = _tweener.GetPointOnPath(ratio);
    Debug.Log("tweener ratio:"+ratio);
    Vector3 _CurDirection = (nextpos-MapManager.instance.VertexZForPos(gameObject.transform.localPosition)).normalized;

    float angle = Vector2.Angle(_CurDirection,Vector3.up);
    if(_CurDirection.x<0)
    angle = -angle;

    gameObject.transform.localEulerAngles = new Vector3(0,angle+45,0);
    }

    }

    if I comment "OnPathMoveUpdate" function's code, everything is right. Objects can move alone it's path.
    When I run OnPathMoveUpdate, I get errors below:

    NullReferenceException: Object reference not set to an instance of an object
    Holoville.HOTween.Plugins.PlugVector3Path.GetConstPointOnPath (Single t, Boolean p_updatePathPerc, Holoville.HOTween.Core.Path p_path)
    Holoville.HOTween.Plugins.PlugVector3Path.GetConstPointOnPath (Single t)
    Holoville.HOTween.Tweener.GetPointOnPath (Single t)
    FishController.OnPathMoveUpdate () (at Assets/TownFolk/Scripts/GameController/FishingGame/FishController.cs:205)
    Holoville.HOTween.Core.ABSTweenComponent.OnUpdate ()
    Holoville.HOTween.Tweener.Update (Single p_shortElapsed, Boolean p_forceUpdate, Boolean p_isStartupIteration, Boolean p_ignoreCallbacks, Boolean p_ignoreDelay)
    Holoville.HOTween.Tweener.GoTo (Single p_time, Boolean p_play, Boolean p_forceUpdate, Boolean p_ignoreCallbacks)
    Holoville.HOTween.Core.ABSTweenComponent.GoTo (Single p_time, Boolean p_forceUpdate)
    Holoville.HOTween.Sequence.Update (Single p_shortElapsed, Boolean p_forceUpdate, Boolean p_isStartupIteration, Boolean p_ignoreCallbacks)
    Holoville.HOTween.Core.ABSTweenComponent.Update (Single p_elapsed)
    Holoville.HOTween.HOTween.DoUpdate (UpdateType p_updateType, Single p_elapsed)
    Holoville.HOTween.HOTween.Update ()

    Can anyone helps me out?

    Thanks a lot!
     
  48. Madgeniy

    Madgeniy

    Joined:
    Apr 21, 2012
    Posts:
    14
    So, I have another issue.
    I write:
    Code (csharp):
    1.  
    2.         Sequence mySequence = new Sequence (new SequenceParms ().OnComplete (deletePrewObjects).AutoKill(true).Loops(1));
    3.         mySequence.Append (HOTween.To (m_mainPanel.transform, 2, "localPosition", new Vector3 (m_mainPanel.transform.position.x, screenHeightHalf, m_mainPanel.transform.position.z)));
    4.         mySequence.Append (HOTween.To (m_previewer.transform, 2, "position", new Vector3 (m_previewer.transform.position.x, screenHeightHalf, m_previewer.transform.position.z)));
    5.         mySequence.Append (HOTween.To (m_previewer.m_cameraCarousel.transform, 2, "position", new Vector3 (m_previewer.m_cameraCarousel.transform.position.x, screenHeightHalf, m_previewer.m_cameraCarousel.transform.position.z)));
    6.         mySequence.Play ();
    7.  
    But after 2 sec I have premanently 1 tween, that I can't kill. What I should do?
     
    Last edited: Dec 5, 2012
  49. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Bowie Xu: it looks like you caught some kind of bug. Gonna look into it and release a fix when I'll release the new update, which will also contain straight path movement (probably within tomorrow).

    @Madgeniy: since you're using Append, and not Insert, your Sequence should last 6 seconds, with every tween following the completion of the previous one. Could you explain me better what happens after those 2 seconds?
     
  50. Madgeniy

    Madgeniy

    Joined:
    Apr 21, 2012
    Posts:
    14
    Thanks, now I use Insert method instead of Append, but I still have running sequence that can't be completed or stopped, I want to avoid this behaviour.