Problems with Anim Binder

I’m trying to set up a basic animation graph, like in this example: PlayCanvas | HTML5 Game Engine

When I’m trying to run it, I’m getting issues. For one thing, the key down event seems to be firing multiple times, when it seems like the code shouldn’t permit that because it’s supposed to set the state to ‘Walk’ which should mean it won’t fire again. But I put a console log in and you can see it fires over and over while the key is held down.
Secondly, it doesn’t smoothly transition to the walk animation, it does nothing for a few moments, then fires a few errors into the console, and then transitions. Releasing the key does not seem to transition back to the idle pose. Here are the errors that appear:

Anim Binder: Multiple animation curves with the path RootNode/graph/localPosition are present in the Root/Coyote/RL_BoneRoot graph which may result in the incorrect binding of animations
Anim Binder: Multiple animation curves with the path RootNode/graph/localRotation are present in the Root/Coyote/RL_BoneRoot graph which may result in the incorrect binding of animations
Anim Binder: Multiple animation curves with the path RootNode/graph/localScale are present in the Root/Coyote/RL_BoneRoot graph which may result in the incorrect binding of animations
Anim Binder: Multiple animation curves with the path Coyote_Mesh/graph/localPosition are present in the Root/Coyote/RL_BoneRoot graph which may result in the incorrect binding of animations
Anim Binder: Multiple animation curves with the path Coyote_Mesh/graph/localRotation are present in the Root/Coyote/RL_BoneRoot graph which may result in the incorrect binding of animations
Anim Binder: Multiple animation curves with the path Coyote_Mesh/graph/localScale are present in the Root/Coyote/RL_BoneRoot graph which may result in the incorrect binding of animations

Searching the forum here I found another post with a similar issue: Anim Binder warnings in console

Where @Elliott explained that it’s probably due to multiple bones having the same name, or a mismatch of hierarchy. The mesh and animations were all exported at the same time from Character Creator 4, so I would assume they would have the same hierarchy. Looking through the hierarchy, it also doesn’t seem like there are any bones with duplicate names.

Can anyone help me with what’s going on here?

Here is the project: PlayCanvas | HTML5 Game Engine

That would be the repeat key of the browser kicking in when you hold down a key. Two ways to fix this is:

  1. Check for ‘repeat’ property in the raw keyboard event
AnimController.prototype.keyDown = function (e) {
    if (e.event.repeat) {
        return;
    }

    if ((e.key === pc.KEY_W) && (this.entity.anim.baseLayer.activeState !== 'Walk')) {
        this.entity.anim.setBoolean('walk', true);
        console.log('WALK!');
    }
};
  1. Or use this.app.wasPressed(pc.KEY_W)/this.app.wasReleased(pc.KEY_W) in the update loop instead. eg
if (this.app.wasPressed(pc.KEY_W)) {
        this.entity.anim.setBoolean('walk', true);
        console.log('WALK!');
}

The issue is that Exit Time on the transitions were set to 1 which means the transition would only be available at the end of the current animation.

Changing both transitions to Exit time of 0 matches the tutorial and fixes the issue going from/to walk/idle smoothly.

This is due to mismatch between the model rig and animation paths where the animation is looking for a path that has ‘RootNode’ at the start which can be seen when we look at the animation in the viewer:

But the model does not have this:
image

This is related to this ticket: https://github.com/playcanvas/editor/issues/602

A way to fix this is to add an Entity to the be the parent of Coyote and renaming Coyote to be RootNode. The scales and rootnode on the Anim Component would also need to be updated.

Here is the fixed project: https://playcanvas.com/project/965868/overview/f-charactertests

1 Like

Amazing, thank you so much!

Quick question: why can you not simply rename the entity ‘Coyote’ as ‘RootNode’ and put the anim and script components on that? What is it that necessitates creating the new entity/parent?

Due to the scale that the importer introduces to the entity hierarchy, the template parent (‘Coyote’) is set at 0.01.

And as the animation changes the RootNode scale to 1, it would mean at runtime, it would be VERY large :sweat_smile:

Also AFAIK, it starts looking for the children of the RootBone that is assigned to the anim component. So I had to make the RootNode entity to be the child of something hence all the workarounds I had to do in the video.

Moving the anim components and scripts is a personal organisation thing. I prefer them to be on the parent entity of the whole object if possible.

@Elliott may know more once he is back in the office.

1 Like

Thanks so much for your answers, I really appreciate it.