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

Reverse ease graph on RepeatStyle::PingPong #24

Open
musjj opened this issue Jun 9, 2024 · 1 comment
Open

Reverse ease graph on RepeatStyle::PingPong #24

musjj opened this issue Jun 9, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@musjj
Copy link
Contributor

musjj commented Jun 9, 2024

Right now, it looks like that when a tween is being repeated with RepeatStyle::PingPong the direction of the ease is not reversed.

So for example when using EaseFunction::BounceOut, the movement is bounced at the end of the movement in the first loop, but then bounced at the start in the second loop.

I'm not sure which is more intuitive and I'm pretty sure that there might be a use-case that require this behavior. But I feel being able to reverse the ease would a pretty useful feature.

@Multirious
Copy link
Owner

Multirious commented Jun 9, 2024

RepeatStyle::PingPong is a calculation in bevy_time_runner where it literally reverse the TimeDirection on 'bounce'. This is the simplest implementation and most intuitive behavior IMO. This should supports most looping animations that will be made, I hope...

Short term solution:
For any specific animation style you want to animate will need to be done specifically in 2 part and use RepeatStyle::WrapAround.
Eg.

commands.animation().repeat(Repeat::Infinitely).insert(sequence((
    tween(duration, EaseFunction::BounceOut, ...),
    tween(duration, EaseFunction::BounceIn, ...)
)));

System solution:
There could be a method to retrieve the 'inverse' ease version (In <-> Out). And then every time the time_runner 'bounce', Run a system that inverse the ease.
Example API could looks like

commands.spawn(InverseEaseOnBounce).animation().repeat(Repeat::Infinitely).insert(sequence((
    tween(duration, (EaseFunction::BounceOut, InverseThis), ...), // or DontInverseThis marker
)));

InverseEaseOnBounce is a marker component for the animation root. The ease inversing systems will then selectively target this animation to inverse any ease with the marker InverseThis. Of course you can also implement without the marker too if you want the system to apply everywhere.
You can have a try implementing this method in your project. This might be a useful feature but I think I need more people responding to this issue to confirm. If that did happen then I'm happy to put this feature into the crate!

@Multirious Multirious added the enhancement New feature or request label Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants