const B = sceneAssetsManager.addMeshTask('A', '', 'https://xxxx', '11256.glb')
B.onSuccess = (task) => {
task.loadedMeshes[0].position = new Vector3(0, 0, -groundSize / 2 + 4)
task.loadedMeshes[0].scaling = new Vector3(heroScale, heroScale, heroScale)
BIdle = scene.getAnimationGroupByName('11256_idle')
BAttack = scene.getAnimationGroupByName('11256_attack')
BDie = scene.getAnimationGroupByName('11256_die')
BEnter = scene.getAnimationGroupByName('11256_enter')
BIdle.start(true, 1.0, BIdle.from, BIdle.to, false)
}
This is my code. I will get the animation data after the model is successfully pulled, and then execute the default model of idle. If I don’t execute idle, it will automatically execute attack
In the next case, I will choose to play the action data obtained above according to the state in the render function
createScene().then((scene) => {
engine.runRenderLoop(function () {
if (_vue.state == 17) {
console.log('B die')
BDie.start(false, 1.0, BDie.form, BDie.to, true)
} else if (_vue.state == 18) {
console.log('B attack')
BIdle.stop()
BAttack.start(false, 1.0, BAttack.form, BAttack.to, true)
}
else if (_vue.state == 19) {
console.log('B idle')
BIdle.start(true, 1.0, BIdle.form, BIdle.to, true)
} else if (_vue.state == 20) {
console.log('B enter')
BEnter.start(false, 1.0, BEnter.form, BEnter.to, true)
BEnter.onAnimationEndObservable.add(()=>{
BIdle.start(true, 1.0, BIdle.form, BIdle.to, true)
})
}
})
For the attack action, I have to use idle first, and the rest of the actions can be called directly, because the attack action is the default action?