Multiple collisions with physics engine

Hello, I am fairly new to Babylonjs, and I cant seem to figure out how to detect collisions among n objects, so say I had a scene with a bunch of bouncing balls and I wanted the ball to change its color to a random color every time it collides with another ball or the ground. How would i go about inserting my own function to execute when a collision is detected from the physics engine. I have tried putting a function at mesh.physicsImpostor.onCollide but it doesn’t seem to execute when I run the code, and registering every ball one at a time using the mesh.physicsImpostor.registerOnPhysicsCollide seems tedious, (I realize i could also use an array here but the bouncing balls is just an example of what I am trying to achieve and in reality the meshes that will collide are in many different groups). So is there a way to execute code on a mesh when it collides with anything without having to register everything?

Hey and welcome!

Do you mind creating a simple repro in the playground? It will be easy for us to help you then with the code you are using