We spoke to each other by private message and found that there were two main issues:
With the anim state graph, it won’t animate unless every state in the graph has been given an animation on the anim component.
ie:
this.app.assets.loadFromUrl(path, 'container', (a,b)=>{
const entity = b.resource.instantiateRenderEntity({
castShadow: true
})
// Create a root node for this entity to match what the animation expects
const rootNode = new pc.Entity('RootNode');
this.app.root.addChild(rootNode);
rootNode.addChild(entity);
// Scale the entity to match what the animation expects
rootNode.setLocalScale(0.01, 0.01, 0.01);
entity.setLocalScale(1, 1, 1);
rootNode.addComponent('anim',{
activate:true
});
rootNode.anim.loadStateGraph(this.graphAsset.resource);
const idleAnimAsset = this.app.assets.find('idle.glb', 'animation');
const upBallAnimAsset = this.app.assets.find('UpBall.glb', 'animation');
const lKickAnimAsset = this.app.assets.find('kick_L.glb', 'animation');
const rKickAnimAsset = this.app.assets.find('kick_R.glb', 'animation');
const failAnimAsset = this.app.assets.find('fail.glb', 'animation');
rootNode.anim.assignAnimation('idle', idleAnimAsset.resource);
rootNode.anim.assignAnimation('New state 6', upBallAnimAsset.resource);
rootNode.anim.assignAnimation('lHit', lKickAnimAsset.resource);
rootNode.anim.assignAnimation('rHit', rKickAnimAsset.resource);
rootNode.anim.assignAnimation('fail', failAnimAsset.resource);
// The graph doesn't have any anim mappings, these have to be done on
// component. All states need to have an animation for any animation
// to play
})
The model and animation had a mismatch in hierarchy too as it looked like model wasn’t rigged correctly for the animation used or the animation was using the correct model rig. For the sake of the project, I had to add an extra node in the hierarchy and change the scale to have it animate.
// Create a root node for this entity to match what the animation expects
const rootNode = new pc.Entity('RootNode');
this.app.root.addChild(rootNode);
rootNode.addChild(entity);
// Scale the entity to match what the animation expects
rootNode.setLocalScale(0.01, 0.01, 0.01);
entity.setLocalScale(1, 1, 1);
TLDR, the animation and model had a mismatch in the rig 