Find out the number of entities from inside a trigger volume

Hello, I request your help again. I need to detect and check the number of active entities inside a trigger box. My issue is that I cannot seem to see function to return all the overlapping entities. My first tackle on the problem was to count the entities on trigger enter and trigger leave but this creates another issue: sometimes the entities get destroyed and there is no way to tell from which trigger box they get destroyed (multiplayer game using

My second tackle was to use raycasts but from my understanding, pc.RaycastResult returns only one entity rather than an array.

Can anybody point me in the right direction? How can I detect accurately the number of entities from inside a trigger volume?

Thank you very much!

Sounds like you are using the physics engine?

Do all the entities have a rigidbody/collision component?

I think there might be a raycast all function in Bullet but I can’t remember if it is exposed in Ammo :thinking: @mikefinch Do you know anything about this?

Technically, Ammo returns current count of intersections.

Then PlayCanvas filters them to see is there are new contacts and then fires event. Same for leave.

I would suggest to store current trigger box in Entity and do your magic with that before destroying.

I thought of using this but seemed to me that I might complicate things more that I should.

Seems that storing the trigger and telling it when to remove is the best option after all.

Thank you very much!