[SOLVED] Destroying the other object that hits it with the trigger

My object A has a rigid body.
The rigid body does not exist in my object B.
Object B has a script and how can I destroy object A with that script trigger?

Thank you in advance for your help.

TriggerBall.prototype.onTriggerEnter = function (triggerEntity) {

    if (triggerEntity.tags.has('tag name')) {
        //destruction process
    }
};

Hey, you will need to add either collider or trigger on object B to make this work. You can read more about the collision and trigger components and how they interact with each other here

1 Like
triggerEntity.destroy();

So triggerEntity is in this case object A and not the trigger entity object B.

1 Like

First of all, thank you very much for your answers. I couldn’t get an immediate response. The reason for this was that I had to go to the hospital urgently.

triggerEntity.destroy();

this answer solved my problem.

2 Likes