Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combining Eases #678

Open
Tehenauin opened this issue Apr 10, 2024 · 1 comment
Open

Combining Eases #678

Tehenauin opened this issue Apr 10, 2024 · 1 comment

Comments

@Tehenauin
Copy link

Since I wanted to have an ease that starts with more acceleration than on the end and I didn't want to use Animation curves, I thought it would be great, to be able to combine two interpolate between two eases. Unfortunately I couldn't find a feature that does what I wanted, but I was able to create an Easefunction on my own.

this is what I came up with:

 public static EaseFunction CombinedEase(Ease easeIn, Ease easeOut, Ease interpolationEase = Ease.Linear)
 {
     return new EaseFunction((time, duration, overshootOrAmplitude, period) =>
     {
         float t = time / duration;
         float eIn = EaseManager.Evaluate(easeIn, null, t, 1, overshootOrAmplitude, period);
         float eOut = EaseManager.Evaluate(easeOut, null, t, 1, overshootOrAmplitude, period);
         float ti = interpolationEase == Ease.Linear ? t : EaseManager.Evaluate(interpolationEase, null, t, 1, overshootOrAmplitude, period);
         return (1-ti)*eIn + ti*eOut;
     });
 }

the interpolationEase gives control over how the the eases are blended. this gives a lot of flexibility.

With this function you can even get an ease that starts fast, becomes slower and ends fast again, which isn't possible with the default eases. You achieve that by putting an "Out Ease" in the easeIn field and an "In Ease" in the easeOut field.
example: transform.DOMove(targetPosition, duration).SetEase(CombinedEase(Ease.OutQuad, Ease.InQuad))

I think it would be great to have something like this in DOTween by default. What do you think?

@Tehenauin
Copy link
Author

It would also be great if DOVirtual.EasedValue(..) would work with EaseFunctions too.
That would make it easier for me to use my functions since I am actually not using it for tweening but for manipulating waypoints for a tweening path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant