[SOLVED] Detect animation end

Hi ,
How can I detect whether animation is completed or ongoing. if completed then destroy that particular entity using code.

var CollisionDetection = pc.createScript('collisionDetection');

CollisionDetection.prototype.initialize = function () {
    this.entity.collision.on('collisionstart', this.onCollision, this);
    this.counter = 0;
};

CollisionDetection.prototype.onCollision = function (res) {
    if (res.other.name.startsWith("Enemy")) {
        res.other.script.enemyRaycastFire.clearInterval();
        res.other.script.enemyMovement.isEnemyKilled = true;
        res.other.anim.setBoolean('Die', true);
        this.entity.destroy();
        setTimeout(() => {
            // res.other.destroy();
            console.log(res.other.anim)
        }, 3000)
    } else {
        this.entity.destroy();
    }
}

thank you

Hi @gouthamamin!

I think the topic below can help you. :point_down:

Thank you

1 Like