[SOLVED] Having a problem with collision

Here’s my project PlayCanvas 3D HTML5 Game Engine

I’m having a problem on collision with an entity it does not destroy the entity but the sound works

Hi @Miggy_Dacillo and welcome! You check if the name is ‘coin’, but this entity has no components, because the components are on a child entities. So there is never a collision with the ‘coin’ entity. Strange that the sound is playing. :face_with_monocle:

It’s because you don’t open and close your statement with the needed brackets.

To fix both problems you can try something like below.

Collision.prototype.onCollisionStart = function (result) {
    if (result.other.parent.name === "coin") {
        result.other.destroy();
        this.entity.sound.play("sound");
    }
};

thank you, let me try this

thank you so much it already work

1 Like