Hey!
I’m working on adding an avatar in the scene and moving it onclick. I have added the avatar and animation separately (as it is needed) and used this example as a reference: https://playground.babylonjs.com/#14GLAR#4
When I click on “Move” button, I get -
Error: Cannot read properties of undefined (reading ‘getRestPose’) and the functionality fails.
In default condition, animations are working fine.
Hello and welcome to the Babylon community! As we suggest on our template, it’s suggested you add your own playground with your code so we can have a better idea of how to help
Hi @carolhmj! You can now see my avatar on PG. I have tried using Github to access the animation file that I’m using locally on my laptop. The error is appearing when I try to execute the ‘moveAvatar’ functionality.
The target of the animations you are loading are being disposed, and therefore the animation has no target. this is the reason for the exception (line 54 in your playground).
Hi @RaananW!
I thought the same but I’m loading the mesh and animations separately. The ‘mesh.dispose()’ line is to dispose the mesh of the glb file that I’m using to get Animations.
I’m not sure if the problem is due to the dispose line or something else. If you’re sure, can you suggest me a solution.
the “Armature” node is named “Armature.001” in the 2nd avatar:
I used “Armature” instead of “Armature.001” when searching for children in the PG below but a better fix would be to correct the naming in the DCC tool. Also, you should pass avatarMesh and not armatureMesh to copy() otherwise “Armature” will not be found when searching for children (destMesh.parent does not go high enough in the hierarchy if destMesh==armatureMesh)
the 3rd anim is a morph target animation, not a rigged animation. You should skip it in the copy() function.