0

Im using LeanTween to animate an UI, the show animations works perfectly, but the hide animation is 3 times slower... any idea on what can be causing this?

My animation time is 1.5F and menuStartBtn is a RectTransform

void ShowStartMenu()
{
    LeanTween.moveY(menuStartBtn, 0.0F, animationTime).setEase(LeanTweenType.easeOutElastic);
}

void HideStartMenu()
{
    LeanTween.moveY(menuStartBtn, -192.0F, animationTime).setEase(LeanTweenType.linear);
}
Chico3001
  • 1,853
  • 1
  • 22
  • 43
  • 1
    It's probably that you are using two different tween types. If you use linear for show, does it not have the same speed? Why not just use `animationTime * 0.333f` for hide? – Ruzihm Dec 01 '20 at 22:59
  • The problem is that i would love to have different animation types for different UI elements, if I have to setup a correction for each animation type its going to be a nightmare, perhaps i will have to try another tweening library to see if it handles the same animation speed for all the easing types.. – Chico3001 Dec 02 '20 at 02:05
  • 1
    It's impossible to have a linear tween, a cubic tween, a quadratic tween, and an elastic tween all have the same speed. If they were, then they would all be the same type of tween. To me, it is unclear what you are asking for here. – Ruzihm Dec 02 '20 at 03:54
  • @Chico3001 What do you mean by "3 times slower"? Do you mean the velocity (how far it moves each frame) or the time it takes to complete? – Immersive Dec 02 '20 at 05:07
  • @Immersive yes, the time it takes to complete the animation, on EaseOutElastic if i set 1.5F it takes 1.5seconds to complete, but on linear it takes about 4 Seconds to complete the animation – Chico3001 Dec 02 '20 at 05:51
  • @Ruzihm i havent seen the internal operation of LeanTween but if you see its documentation the third parameter is "time The time to complete the tween in" http://dentedpixel.com/LeanTweenDocumentation/classes/LeanTween.html#method_LeanTween.move – Chico3001 Dec 02 '20 at 05:53
  • 1
    @Chico3001 That's not the same thing as speed - animation speed should be slower for linear than ease out elastic at first, then the speed of the elastic oscillates around 0, and the speed of linear remains positive. My only guess is that you are not counting the time the elastic ease out is "bouncing" at the end of its animation. [See here for an example of ease out elastic vs linear over the same period of time](https://easings.net/#easeOutElastic) – Ruzihm Dec 02 '20 at 07:02
  • @Ruzihm "Speed" can refer to anything that occurs over time. Saying "the speed of the animation" is not incorrect, it's just ambiguous. – Immersive Dec 02 '20 at 10:53
  • @Chico3001 If you use the easeOutElastic in your HideStartMenu tween, does it still animate slowly? – Immersive Dec 02 '20 at 10:56
  • 1
    @Ruzihm danm... you are right! i was counting the animation just to the point where it shows but it keeps bouncing a lot just not noticeably – Chico3001 Dec 02 '20 at 16:48
  • 2
    @Immersive I'm starting to think it's more likely that they don't mean they want the animations to have the same time to *complete*, they want the same time to reach the destination position the *first* time. I don't know about `LeanTween` implementation of ease out elastic, but the [implementation on easings.net](https://easings.net/#easeOutElastic) has that for [t=0.075](https://www.wolframalpha.com/input/?i=pow%282%2C+-10+*+t%29+*+sin%28%28t+*+10+-+0.75%29+*++%282+*+PI%29+%2F+3%29+%2B+1+%3D+1%3B+t%3E0) so if it is the same you could do `animationTime/0.075` for ease out elastic – Ruzihm Dec 02 '20 at 16:54

0 Answers0