#How to play animation for specific entity?
3 messages · Page 1 of 1 (latest)
// Get the animation controller component, which is a child of the player entity.
let mut iter = animation_query
.iter_many_mut(hierarchy_query.iter_descendants(entity));
let animation_player = iter.fetch_next();
let Some(mut animation_player) = animation_player else {
return;
};
animation_player.play(...);
Where:
animation_query: Query<&mut AnimationPlayer>,
hierarchy_query: Query<&Children>,
https://bevy-cheatbook.github.io/features/parent-child.html#accessing-the-parent-or-children is a good reference here.
The tricky part is that the animation player is spawned as a child of the entity that has the SceneBundle, thus the hierarchy_query logic.