Using meshes to trigger collision events

Hello
For some reason, in the example below onTriggerCollisionObservable is not triggered if my trigger shape is constructed based a sphere mesh using BABYLON.PhysicsShapeMesh method. However, if I construct the trigger shape using BABYLON.PhysicsShapeSphere of the same diameter, I am getting the expected results

To switch the behavior, comment out / uncomment out lines 39 and 40
Please let me know what I am doing wrong
Thank you,
David

@eoin it seems that mesh shapes are not reporting trigger events?

Whoops, looks like we broke something when adding support for filtering triggers to raycasts (my fault, acutally.) I’ll get this fixed and tested. One thing to be careful of though, is that mesh triggers are more CPU intensive than “simple” shapes like spheres or hulls and meshes will only detect cases when the body is overlapping the mesh surface (i.e. if the body is completely inside a mesh sphere, like in the image below it won’t raise trigger events) - maybe this is what you want, but something to be aware of.

3 Likes