Update morph_targets
and many_foxes
examples to use observers
#20531
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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
andmany_foxes
examples to use observers.I also made a few tweaks and fixes to
morph_targets
.update_weights
feature that isn't in the example.AnimationToPlay
component as theanimated_mesh
example.name_morphs
system to be event driven and print the asset name.I haven't updated the
animated_mesh_control
,animated_mesh_events
, andanimation_masks
examples, which still useAdded<AnimationPlayer>
.Testing