[SOLVED] Triggers not detecting entities with rigidbody group

I am currently working on a project which uses rigidbodies for both the player and enemies. While I have used collision masks to successfully allow players and enemies to ignore one another while colliding with the wall and ground, they no longer interact with trigger entities.

Is there any way for me to find out which collision mask is required to interact with triggers as they do not have a rigidbody component?

How have you set the masks? PlayCanvas has predefined bits uses for triggers. The best palace to look is the GitHub repo for the engine. https://github.com/playcanvas/engine/blob/master/src/framework/components/rigid-body/constants.js

1 Like

Many thanks for that link, it really helped that i can actually see the group numbers. I had followed the script I saw in a different topic and had first cleared the group and masks (by setting them to 0) before reapplying a new group and mask bit.

Edit: How do I refer to these numbers, as I had been using the bit shift on integers ( this.entity.rigidbody.group |= 1 << 1)

Currently, the first 8 bits are reserved by the engine so you should be starting from the 8th bit onwards.

If you set your constants to be the same values as the ones set aside for user use (pc. BODYGROUP_USER_1, pc. BODYGROUP_USER_2 etc)

You can just do what you have been doing now without the bitshifting.

Eg. this.entity.rigidbody.group |= pc.BODYGROUP_USER_1

Or if you want to continue with the bitshifting method, just start from the 9th bit onwards:
this.entity.rigidbody.group |= 1 << 8

1 Like

Thanks for the reply, based on your input, my approach had been flawed as I had been unknowingly using bits reserved by the system and ended up with weird results.

On an added note, is there a way to access the trigger mask (16) with a bitwise shift?

Sorry, run that by me again?

I’ve noticed in the link page that triggers appear to reside under pc.BODYGROUP_TRIGGER: 16.

Using the mask system to target the bodygroup allowed me to finally get my triggers to be detected by the colliders but i was wondering if I could use e.g. 1 << 16 to access the trigger layer (although the example i gave did not seem to work.

pc.BODYGROUP_TRIGGER: 16 is the value of 16, not the 16th bit. So it would be group |= pc.BODYGROUP_TRIGGER

I’m not sure why there is a body group for trigger especially without looking at the engine code.

Edit: I see it now. It’s to stop triggers from triggering other triggers.

1 Like

So based on your response, the only way for a rigidbody with a custom mask to interact with triggers is to manually call for the rigidbody.mask |= pc.BODYGROUP_TRIGGER

I wish there was a better way to do this, but it’s at least clearer for now.

No, I’m just saying it is used by the engine to prevent triggers from triggering other triggers.

Otherwise the usual rules apply about groups and masks. You don’t have to use pc.BODYGROUP_TRIGGER

Here is an example of me using physics masks: https://playcanvas.com/project/519294/overview/physics-mask

Edit: https://www.panda3d.org/manual/index.php/Bullet_Collision_Filtering This should explain the groups and masks.

1 Like

I was wrong, you are right. For the default triggers, you have to do what you said above.