-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Add Support for Triggering Events via AnimationEvents
#15538
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
Add Support for Triggering Events via AnimationEvents
#15538
Conversation
|
The generated |
|
The generated |
rename events -> animation_events rename events -> animation_events
eda8fe2 to
d2ed656
Compare
|
I would prefer to not add a new model, would it be possible to work with the animated fox in examples? if not, the model should be added to https://github.com/bevyengine/bevy/blob/main/CREDITS.md with its licence and a link to the opengameart.org page |
That seems doable. would you prefer I added events to the existing |
|
I removed the |
ChristopherBiscardi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall love this feature, I've written implementations in my games for it in the past. I ran the examples (including the older ones that got removed) and feel like adding events is very usable.
I'm curious if the difference between manual impls and derived impls running at different times will be a pain point for learning the feature from examples.
One thing I wonder about is timeframe vs frame count for add_event. Will the time offset scale if time is sped up/slowed down (such as for a slow-motion effect)? and how does someone figure out what the time offset is supposed to be? If I was building an animation in another program wouldn't it be more likely that I was calculating it based on the frame data? Perhaps time and frame versions of specifying could be useful.
Co-authored-by: Chris Biscardi <chris@christopherbiscardi.com>
Yep, it was a bad idea on my part to make an example that required a custom implementation since it modifies
In the bunny example I had a comment that explained how to determine the correct time, it's essentially As for an alternate |
# Objective Pausing the `animated_fox` example perfectly as one of the feet hits the ground causes the event to be triggered every frame. Context: #15538 ## Solution Don't trigger animation events if the animation is paused. ## Testing Ran the example, I no longer see the issue.
|
Thank you to everyone involved with the authoring or reviewing of this PR! This work is relatively important and needs release notes! Head over to bevyengine/bevy-website#1716 if you'd like to help out. |
Objective
Add support for events that can be triggered from animation clips. This is useful when you need something to happen at a specific time in an animation. For example, playing a sound every time a characters feet hits the ground when walking.
Closes #15494
Solution
Added a new field to
AnimationClip:events, which contains a list ofAnimationEvents. These are automatically triggered inanimate_targetsandtrigger_untargeted_animation_events.Testing
Added a couple of tests and example (
animation_events.rs) to make sure events are triggered when expected.Showcase
Eventsneed to also implementAnimationEventandReflectto be used with animations.Events can be added to an
AnimationClipby specifying a time and event.And optionally, providing a target id.
I modified the
animated_foxexample to show off the feature.