# Triggering the Play All animtionclip

**URL:** https://forum.8thwall.com/t/triggering-the-play-all-animtionclip/6188
**Category:** Technical Support
**Tags:** studio
**Created:** [April 24, 2025, 3:29pm UTC](https://forum.8thwall.com/t/triggering-the-play-all-animtionclip/6188 "2025-04-24T15:29:55Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Nwankwo\_Micheal](https://avatars.discourse-cdn.com/v4/letter/n/8491ac/32.png) [@Nwankwo\_Micheal](https://forum.8thwall.com/u/Nwankwo_Micheal)
#### Post date: [April 24, 2025, 3:29pm UTC](https://forum.8thwall.com/t/triggering-the-play-all-animtionclip/6188/1 "2025-04-24T15:29:55Z")

</div>

Hello Everyone I’m trying to trigger the "Play All "animation clip via code and it doesn’t work, other animation clips work when i type out their animation clip name except “Play All”

```auto
import * as ecs from '@8thwall/ecs'

ecs.registerComponent({
  name: 'PlayerAnimations',
  data: {
    currentAnimation: ecs.string,
  },

  schema: {
    inputManager: ecs.eid,
  },

  stateMachine: ({world, eid, schemaAttribute, dataAttribute}) => {
    const animations = ['Idle', 'Walk', 'Attack', 'Play All']
    let currentIndex = 0

    const playAnimation = (animationName, playSpeed, canLoop) => {
      const animationComponent = ecs.GltfModel.get(world, eid)
      if (animationComponent) {
        ecs.GltfModel.set(world, eid, {
          animationClip: animationName,
          timeScale: playSpeed,
          loop: canLoop,
        })
        dataAttribute.cursor(eid).currentAnimation = animationName
        console.log(`Swapped to animation: ${animationName}`)
      }
    }

    const handleNext3 = () => {
      currentIndex = (currentIndex + 1) % animations.length
      const nextAnimation = animations[currentIndex]
      playAnimation(nextAnimation, 1, true)
    }

    ecs.defineState('idle').initial()
      .onEnter(() => {
        playAnimation('Idle', 1, true)

        const inputManagerId = schemaAttribute.cursor(eid).inputManager
        if (inputManagerId) {
          world.events.addListener(inputManagerId, 'Scene1', handleNext3)
        }
      })
      .onExit(() => {
        const inputManagerId = schemaAttribute.cursor(eid).inputManager
        if (inputManagerId) {
          world.events.removeListener(inputManagerId, 'Scene1', handleNext3)
        }
      })
  },
})

```

 ![Screenshot (213)](https://us1.discourse-cdn.com/flex019/uploads/x8thwall/original/2X/a/ada42f9519e28976a69d627a3dbdfa84d817c497.png)

---

<div class="post-metadata">

### Author: ![GeorgeButler](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/georgebutler/32/1903_2.png) [@GeorgeButler](https://forum.8thwall.com/u/GeorgeButler)
#### Post date: [April 24, 2025, 6:54pm UTC](https://forum.8thwall.com/t/triggering-the-play-all-animtionclip/6188/2 "2025-04-24T18:54:14Z")

</div>

Use `*` instead of the animation clip name and it will play them all. 🙂

---

<div class="post-metadata">

### Author: ![Nwankwo\_Micheal](https://avatars.discourse-cdn.com/v4/letter/n/8491ac/32.png) [@Nwankwo\_Micheal](https://forum.8thwall.com/u/Nwankwo_Micheal)
#### Post date: [April 25, 2025, 1:15pm UTC](https://forum.8thwall.com/t/triggering-the-play-all-animtionclip/6188/3 "2025-04-25T13:15:02Z")

</div>

it works perfectly, thanks ..  
Do you know how to play animation clips in parts? For example, I want to play the first 2 seconds of an animation when the ‘Next’ event is triggered, and then play the next 2 seconds the next time the ‘Next’ event is triggered.  
Thanks 😊

---

<div class="post-metadata">

### Author: ![GeorgeButler](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/georgebutler/32/1903_2.png) [@GeorgeButler](https://forum.8thwall.com/u/GeorgeButler)
#### Post date: [April 25, 2025, 9:26pm UTC](https://forum.8thwall.com/t/triggering-the-play-all-animtionclip/6188/4 "2025-04-25T21:26:12Z")

</div>

I would make a StateMachine that has a state for each animation, and then just make triggers to go to the next animation.

---

<div class="post-metadata">

### Author: ![Nwankwo\_Micheal](https://avatars.discourse-cdn.com/v4/letter/n/8491ac/32.png) [@Nwankwo\_Micheal](https://forum.8thwall.com/u/Nwankwo_Micheal)
#### Post date: [April 27, 2025, 1:20am UTC](https://forum.8thwall.com/t/triggering-the-play-all-animtionclip/6188/5 "2025-04-27T01:20:15Z")

</div>

Thanks @GeorgeButler

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex019/uploads/x8thwall/original/2X/9/9212a857458f1b03a6accb129e0f8cbea408e3e5.png) [@system](https://forum.8thwall.com/u/system)
#### Post date: [May 1, 2025, 1:20am UTC](https://forum.8thwall.com/t/triggering-the-play-all-animtionclip/6188/6 "2025-05-01T01:20:25Z")

</div>

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.
