Character animation events

Hello PlayCanvas community - im an old skool flash dev with loads of experience and so far ive loved my week playing with PC - Feels like this will be the one for me after a few years looking for my new framework :slight_smile:

Something i am looking for and not seeing:

I have got a character that has fbx animations for different things - how do i set the animations up (script) to listen for end of animation events? Animation end = trigger “this” event.

Thanks in advanced.

1 Like

also im down with animation blending but setting loop in the editor applies to all animations - some have to do things at the end of one play like the death animation.


We don’t currently fire animation events like that. I think you’ll have to manually check the entity.animation.currentTime property against entity.animation.duration property to determine if the animation is finished.

I’ve added a github issue for this though.

Yeah, kind of sucks. You’ll have to set entity.animation.loop = true|false when you play the new animations.

Is there any kind of WHILE function so like:

while ( entity.animation.currentTime <= entity.animation.duration ) {
} else {
entity.animation.loop = false

Attach a script to your animated entity and add this code in the update function:

if (entity.animation.currentTime < entity.animation.duration) {
    // animation is running
} else {
    // animation is finished

Nice one - thanks :slight_smile: