Destroy() not working

When the Fireglock function is called , I want to listen to the bullet’s collisionend event and then destroy it. Everything works as it should and it even executes the code inside the BulletDelete Function which is the collisionend event function of the bullet but the bullet still gets rendered and interacts with the world, I am stuck here. Any help is appreciated

the link for my project : https://playcanvas.com/project/702035/overview/redacted

the Following is the Code responsibile for this

  Weapon.prototype.Fireglock = function  (dt){
    this.force = new pc.Vec3();
      this.bullet = new pc.Entity();
     this.app.root.findByName('Camera').addChild(this.bullet);
    this.bullet.addComponent("model", {
    type: 'box',
});
      this.bullet.tags.add('bullet');
    this.bullet.setLocalScale(0.1,0.1,0.2);
    this.bullet.setLocalPosition(0,0,-0.8);
     this.bullet.addComponent("model");
    this.bullet.addComponent("rigidbody");
   this.bullet.rigidbody.type = pc.BODYTYPE_DYNAMIC;
    this.bullet.addComponent("collision");
    this.bullet.collision.halfExtents = (0.5,0.5,0.1);
     this.force.copy(this.bullet.forward).scale(50);  
this.bullet.rigidbody.applyImpulse(this.force);
 this.app.root.findByName('Camera').removeChild(this.bullet);
      this.app.root.addChild(this.bullet);
      this.bullet.collision.on('collisionend' , this.BulletDelete, this);
     
};
Weapon.prototype.BulletDelete = function () {

    this.bullet.destroy();
    console.log('bullet has been destroyed');

};

Hi @agent178,

Gave it a quick try, it seems all bullets spawned are being destroyed on collision. I can’t see them after they hit the ground.


huh , For me it doesnt seem to work