[SOLVED] Anim: triggering initial state leads to unexpected behaviour

If you don’t want the ‘queue up’ effect, you can use the second parameter of setTrigger to only have it apply for the current frame.

AnimComponent | PlayCanvas API Reference>

this.entity.anim.setTrigger('idle', true);

This way, if the trigger is not consumed in this frame, it gets reset at the end of it.

Also as a side note, I personally prefer to use ‘sub graphs’ over ANY FRAME. With layer.transition , you can transition to any state even if there is no set transition path between the states.

This makes it handy to jump to other parts of the graph.

Example: https://playcanvas.com/project/1061484/overview/f-jump-example

And the code when jumping:

if (this.app.keyboard.wasPressed(pc.KEY_SPACE)) {
   this._anim.baseLayer.transition('Jump', 0.1);
}
2 Likes