[SOLVED] AnimComponent not work with Templates

I am making a project with templates and I am replacing the animation component with the new anim component, but I have a problem when I call that template with the anim component, because the component does not work, the model remains as if it did not have animations, here I attach my draft

https://playcanvas.com/editor/scene/1020032

you will see that there is a character that is saved as a template, called “char_1”,
When I start the game with that character, everything is fine, the animation works.
the problem comes when I try to instantiate that same template from my “Assets”, I wrote a function that does it for what tests is this:

crearPlayerTest();

running the function on the console will create the same character template, but the Anim component no longer works, as if it was disabled, hopefully someone can help me, thanks.

@Elliott - any thoughts?

Hi @ignacio_padilla! I can’t find the function crearPlayerTest. In which script is it? Did you apply all needed changes to the template, because I see a script enabling is not applied to the template. This script seems to be controlling your anim state graph.

1 Like

Odd, it should work. I’ve done a similar thing in this project for Bitmojis: https://playcanvas.com/project/721733/overview/3d-bitmoji-library

Build: 3D Bitmoji Library - PLAYCANVAS

1 Like

the function createPlayerTest is found in Assets / Files / SocketManager.js
The movePlayer.js script is deactivated because it is an MMO project and that script is in charge of the real-time movement of the character, but is activated with createPlayerTest function, the script that is in charge of the animations is in char_1/Body and is called pBody.js

1 Like

Currently no animations have been added, but I don’t know if that is the intention. Other than that, I don’t see anything that stands out to me. Hopefully the PlayCanvas team can help you further.

1 Like

Thanks for the help you gave me, i managed to solve the error, in the Anim/Root Bone
was on char_1/Body of the character and i had to leave it empty.
Sin título

2 Likes

Ah, I think I’ve also made that ‘mistake’ in the past. Thanks for sharing your solution!

1 Like

Oh, I know what the issue could be. It’s possible that the anim component Root Bone reference is still referencing the same body Entity that was on the original template instance and not the new clone’s one :thinking:

This is something we should fix. Thanks for raising and showing the workaround

1 Like

Created ticket: Instantiating a template with an anim component that has Root Bone set doesn't play animations · Issue #3426 · playcanvas/engine · GitHub

1 Like

Thanks Yaustar, yes, the problem is in Root Bone, it already works perfectly adding this line of code to instantiate a new template and add the body to the Root Bone of the new template.

2 Likes