Skip to content

How to play animations on many entities? #20011

Answered by hukasu
jak6jak asked this question in Q&A
Discussion options

You must be logged in to vote
fn play_animation_when_ready(
    trigger: Trigger<SceneInstanceReady>,
    animations: Res<Animations>,
    mut commands: Commands,
    children: Query<&Children>,
    mut player: Query<(Entity, &mut AnimationPlayer)>,
) {
    for child in children.iter_descendants(trigger.target()) {
       if let Ok((entity, mut player)) = player.get(child) {
        let mut animation_transitions = AnimationTransitions::new();
        let playing_animation = animation_transitions
            .play(
                &mut player,
                animations.node_indices[0],
                Duration::from_millis(15),
            )
            .repeat();
        commands
            .entity(entity)
            

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@hukasu
Comment options

hukasu Jul 7, 2025
Collaborator

@hukasu
Comment options

hukasu Jul 7, 2025
Collaborator

@jak6jak
Comment options

@hukasu
Comment options

hukasu Jul 7, 2025
Collaborator

Answer selected by jak6jak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants