*

focus

  • ***
  • 26
    • View Profile
    • blog
DOTweenAnimation overwrite
« on: November 26, 2015, 01:21:02 PM »
Hey guys!

One more silly question from me:
is it possible somehow to overwrite DOTweenAnimation with another DOTweenAnimation on same object?

Let say I have button and 2 animations - to push it with one ease and to pull it back with another one.
I'd like to be able to start the push animation and even if it didn't complete, run the pull back animation (if user cancelled the push before it finished).

Is it possible to make?

Thanks!

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: DOTweenAnimation overwrite
« Reply #1 on: November 26, 2015, 01:44:56 PM »
If you got the references to both tweens, you could stop one and start the other :P

That said, why two separate animations! I find that a single one that is controlled via PlayForward/PlayBackwards is much much better, for these reasons:
1. If the second tween starts while the first one hasn't finished yet, it will still start from the beginning, so you'll see a "jump" to the end of the first tween, and then the backwards animation will start playing. Using the same tween/animation instead has no such issues.
2. An "out" ease is always nice when making something appear, while an "in" ease is nice when making stuff disappear, so the same tween played backwards will have exactly that effect
3. It's a single tween VS 2 :P

*

focus

  • ***
  • 26
    • View Profile
    • blog
Re: DOTweenAnimation overwrite
« Reply #2 on: November 26, 2015, 01:56:11 PM »
Thanks for your super quick response, Daniele!
Two animations allow to control the in and out easing, e.g. slow outQuad for press and nice OutBounce for unpress let me acheive the needed visual effect )

Regarding controlling two tweens via references - yeah, it's a way to go for sure, but still has the issue you described above, when I see the major change of the object (jump).
For now I stay with 2 animations with short duration to reduce change of seeing "jumps" and will think about moving to the Forward\Backwards version instead in future ^^

Thanks for your answer!

Re: DOTweenAnimation overwrite
« Reply #3 on: December 02, 2015, 05:39:41 PM »
Perhaps as a compromise you could still keep your two tweens for the different easing patterns for those regular scenarios where the in or out completes normally.  And then to capture the scenario where the user has perhaps triggered an "out" reverse midway during the not-yet-completed "in", or vice versa, then detect this via IsPlaying and use PlayBackwards in that instance.  After all, if the user halts and reverses a panel slide or whatever it is you're using it for halfway, then the opposite easing type starting at the midpoint wouldn't look normal anyway, so it may well look cleaner just to reverse the current type.

*

focus

  • ***
  • 26
    • View Profile
    • blog
Re: DOTweenAnimation overwrite
« Reply #4 on: December 02, 2015, 05:56:43 PM »
Yeah, you're totally right here, @cynicalwanderer!
Thanks for your comment, I've implemented silly version so far (just starting "out" while "in" is still running) and going to make a rewind version later, just like you described (going to rewind unfinished tween backwards instead of playing opposite animation version).
It should look much better!