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”
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)
}
})
},
})