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

Support a run condition on SpritesheetAnimationPlugin to allow pausing animations #23

Open
mgi388 opened this issue Nov 26, 2024 · 2 comments

Comments

@mgi388
Copy link
Contributor

mgi388 commented Nov 26, 2024

The play animation system always runs:

spritesheet_animation::play_animations.in_set(AnimationSystemSet),

This means if your app wants to pause animations, e.g. when the player presses Pause, the app would have to iterate all animations and pause them itself.

I think it would be better if the plugin received a run_if condition which can be used to determine if the animation system should run. I'd use this to pass run_if(in_state(Unpaused)) to the plugin.

I imagine the implementation would look similar to this: https://github.com/jakobhellermann/bevy-inspector-egui/blob/eaf1ec72819d82254b8de9236246450d86dd2bc1/crates/bevy-inspector-egui/src/quick.rs#L71

WDYT?

@merwaaan
Copy link
Owner

Absolutely, there's no quick way to pause all the animations at the moment.

We could have a "global" running flag accessible from somewhere. Maybe in AnimationLibrary since it's the main plugin resource.

But your idea of using the built-in run_if predicate seems more Bevy-like. Let's go in that direction.

PR welcome :)
(otherwise I'll take a look whenever I get a chance, but that won't be in the next days)

@mgi388
Copy link
Contributor Author

mgi388 commented Nov 27, 2024

I'll need to check if a run condition is the correct way to do this. I just saw https://github.com/bevyengine/bevy/blob/6659f37df1522fd2f927b2afb28ce779cfe3c999/examples/time/virtual_time.rs#L171-L177 and it seems like maybe using VirtualTime could be the correct approach here. Not sure what happens if you want to have some animations working while paused, and some not working. I also need to check how bevy_animation supports or doesn't support this because I'd imagine that bevy_spritesheet_animation should do the same thing.

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

2 participants