Generic tag for collisions

Hi, I am wondering if there is a way to check for collisions with a “type” of object rather than a specific object.

The following code is according to the documentation:

sphereImpostor.registerOnPhysicsCollide(groundImpostor, function(main, collided) {
    main.object.material.diffuseColor = new BABYLON.Color3(Math.random(), Math.random(), Math.random());

What if I wanted to collide with MULTIPLE types of ground scattered all throughout my level? I’m sure I could add all my ground to a list and register a callback for all of them in a loop, but I was wondering if there was a system I wasn’t aware of nestled in BJS that lets me apply a tag to multiple objects so I might simply register a callback for collisions with a type of object instead.

I expect a mesh’s collisionGroup property could help, I’m unfamiliar with fresh documentation on it though.

Pinging @RaananW

the physics collider function accepts also an array of meshes. This array is dynamic - if you keep a reference to it you can add further elements to it.

Other then that you can always use the onCollideEvent callback (defaults to null), which is an older version of the collider. It is rather inefficient thou, as it will execute for EACH collision (you can then filter yourself according to mesh).