Change collision mask of trigger

Hi :slight_smile:

I was wondering, if there is a way to change the collision mask of a trigger, so that it still behaves like a trigger, but only for specific collision groups. For rigidbodies it is easy enough to change it, like the follwing example. But is it possible to set properties like these for triggers as well?

this.entity.rigidbody.group = pc.BODYGROUP_USER_1;
this.entity.rigidbody.group = pc.BODYGROUP_USER_1;

Thanks

Nope, unfortunately not. The filtering masks are hardcoded in the trigger and the body object is hidden, so you can’t change it. If your trigger needs to have a different mask you have 2 options:

  1. Create your own body and add it to the dynamics world. You can follow how it is created in trigger. Don’t forget to destroy it, when done using:
    https://github.com/playcanvas/engine/blob/8f9589f444ee34fee1893d61afdae749726c9ac2/src/framework/components/collision/trigger.js#L34

  2. Another option is to override collision component system, so that it references your own Trigger class. This is a bit more cumbersome, but works well too.

Please, create a feature request to allow changing filtering masks on triggers:

Thats unfortunate, but thanks again for your quick answer :slight_smile:
I will create the feature request

1 Like

Change collision mask for trigger volumes · Issue #5633 · playcanvas/engine · GitHub

2 Likes