Skip to content

Conversation

greeble-dev
Copy link
Contributor

@greeble-dev greeble-dev commented Aug 12, 2025

Objective

Change some examples to follow best practices for playing animations, and as a bonus work around an issue with scenes spawning multiple times.

Background

Examples that play skeletal animations usually have two steps:

  1. Start scene spawning.
  2. Play animations after the scene has spawned.

Different examples use different approaches for triggering part 2, including a scene spawning observer and Added<AnimationPlayer> queries.

The observer approach is arguably best as it's more tightly scoped and easier for users to extend. The other approaches work in simple examples but fall down when users want multiple scenes or animations. See #17421 for more detail.

As a bonus, the scene spawning observer works around a current issue with scenes spawning multiple times - see #20393, #20430. Although there's an argument that this PR shouldn't land until the issue is properly fixed, as these examples are a useful test case.

Solution

Update the morph_targets and many_foxes examples to use observers.

I also made a few tweaks and fixes to morph_targets.

  • Fix documentation referring to an update_weights feature that isn't in the example.
  • Use the same AnimationToPlay component as the animated_mesh example.
  • Change the name_morphs system to be event driven and print the asset name.
    • This is maybe too complex, but could also be nice for users to c&p into their app for debugging.

I haven't updated the animated_mesh_control, animated_mesh_events, and animation_masks examples, which still use Added<AnimationPlayer>.

Testing

cargo run --example morph_targets
cargo run --example many_foxes

@greeble-dev greeble-dev changed the title Update morph_target and many_foxes examples to use scene spawning observers Update morph_target and many_foxes examples to use observers Aug 12, 2025
@greeble-dev greeble-dev added C-Examples An addition or correction to our examples C-Code-Quality A section of code that is hard to understand or change A-Animation Make things move and change over time S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Aug 12, 2025
@greeble-dev greeble-dev changed the title Update morph_target and many_foxes examples to use observers Update morph_targets and many_foxes examples to use observers Aug 12, 2025
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is an improvement regardless of the asset reloading problem.

@andriyDev andriyDev added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Aug 14, 2025
@alice-i-cecile alice-i-cecile added S-Blocked This cannot move forward until something else changes and removed S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels Aug 14, 2025
@alice-i-cecile alice-i-cecile added this to the 0.17 milestone Aug 14, 2025
@alice-i-cecile
Copy link
Member

Waiting to merge until we have a fix for the issue that this revealed.

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Blocked This cannot move forward until something else changes labels Aug 14, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Aug 14, 2025
Merged via the queue into bevyengine:main with commit e2a709e Aug 14, 2025
47 checks passed
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-Code-Quality A section of code that is hard to understand or change C-Examples An addition or correction to our examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants