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

Add Support for Triggering Events via AnimationEvents #15538

Open
wants to merge 66 commits into
base: main
Choose a base branch
from

Conversation

atornity
Copy link
Contributor

@atornity atornity commented Sep 30, 2024

Objective

Add support for events that can be triggered from animation clips.

Closes #15494

Solution

Added a new field to AnimationClip: events, which contains a list of AnimationEvents. These are automatically triggered in trigger_events.

Note that there is currently no guarantee that events will be triggered in the correct order in instances were multiple events are triggered in the same update tick.
Specifically, if the animation looped on this tick and there is one event at the start of the animation, and one event at the end of it, the event at the start will be triggered first simply because events are sorted by the time.
This could probably be accounted for somehow, not sure how though.

Fixed!

Testing

Added a couple of tests and examples to make sure events are triggered when expected.

  • Did you test these changes? If so, how?
  • Are there any parts that need more testing?
  • How can other people (reviewers) test your changes? Is there anything specific they need to know?
  • If relevant, what platforms did you test these changes on, and are there any important ones you can't test?

Showcase

animation events can be added by specifying a time and event.

animation_clip.add_event(1.0, SomeEvent);

and optionally, providing a target id.

let id = AnimationTargetId::from_iter(["shoulder", "arm", "hand"]);
animation_clip.add_event_to_target(id, 1.0, HandEvent);

Added two new animation examples, animation_events and bunny_detective.

CleanShot 2024-10-01 at 16 15 16
The model is my own and it's CC0: https://opengameart.org/content/detective-bunny

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-Animation Make things move and change over time S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Sep 30, 2024
Copy link
Contributor

The generated examples/README.md is out of sync with the example metadata in Cargo.toml or the example readme template. Please run cargo run -p build-templated-pages -- update examples to update it, and commit the file change.

Copy link
Contributor

The generated examples/README.md is out of sync with the example metadata in Cargo.toml or the example readme template. Please run cargo run -p build-templated-pages -- update examples to update it, and commit the file change.

@atornity atornity force-pushed the animation-triggers-experiments branch from eda8fe2 to d2ed656 Compare September 30, 2024 21:11
@atornity atornity changed the title Animation Events Enable Triggering Events from Animations (Animation Events) Oct 1, 2024
@atornity atornity changed the title Enable Triggering Events from Animations (Animation Events) Add Support for Triggering Events via AnimationEvents Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Animation Make things move and change over time C-Feature A new feature, making something new possible S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

animation triggers/events
3 participants