OnTrigger event not working

I have a player with a rigidBody and collision component attached and another entity with just a collision component (a trigger box).
When the player enters the trigger box i want something to happen, however the onTriggerEnter does not seem to register.
On my player I have:

Player_interaction.prototype.initialize = function() {
 this.entity.collision.on('triggerenter', this.onTriggerEnter, this);

Player_interaction.prototype.onTriggerEnter = function (result) {
    console.log("TRIGGERED WITH "+result.other.name); //never fires

I’m expecting this to fire whenever my rigidbody player walks into ANY entity with a collision component but nothing happens. Whats wrong here?

Hi @Grimmy,

Can you try listening for the trigger event on the rigidbody component of the player entity? Like this:

this.entity.rigidbody.on('triggerenter', this.onTriggerEnter, this);

That works perfectly. Thanks!

1 Like

If you look at the collision component documentation: CollisionComponent | PlayCanvas API Reference

There’s a table that shows the events and what components that they are fired on

So you can see here that triggerenter is either fired on the trigger volume or the other rigidbody.