AnimationHandler Not working, Suggestions?

Hello, I made an animation script to blend my animations when the character moves but for some reason it just wont work, here is the link, https://playcanvas.com/editor/code/528170?tabs=10656255 and if this link dont work this is project https://playcanvas.com/editor/scene/579477

You are currently just declaring functions in your update loop so no code is actually being executed.

Taking a small snippet of the update loop, you want to be doing something like:

AnimationHandler.prototype.update = function(dt) {
    var app = this.app;
    if (app.keyboard.isPressed(pc.KEY_W) {
        // Do something
    }
}

So if i do this

AnimationHandler.prototype.update = function(dt) {
var app = this.app;
if (app.keyboard.isPressed(pc.KEY_W) && app.keyboard.isPressed(pc.KEY_S) === false {
direction = ('Walking');
)};
}

Would this work??

It would set the variable direction to the value of "Walking" but unless you do something with that variable, it’s not going to do anything on it’s own.

Edit: I recommend looking at this code sample as it’s doing something similar to what you are trying to do: https://developer.playcanvas.com/en/tutorials/animation-blending/ (keyboard input to trigger an animation).

2 Likes