since I’m new to unity I decided to go easy and learn the ropes by creating a physics powered version of same game (SameGame - Wikipedia) with spheres, cubes, wedges and other objects.
I once coded an old school version of said game and used a 2d array/recursion to find adjacent blocks, but now the playing field is a mess and I guess I have to detect all collisions of an object and then run the same code recursively on them. I know of the OnCollision… functions and could probably keep track of all collisions that way, but having 180 rigidbodies with an n-sized array attached and constant collision checks sounds awfully slow and unnecessary.
So does anybody know how I can detect collisions on demand? I thought about Physics.OverlapSphere(…), but that doesn’t sound too precise with meshes like cubes and whatnot.
I’d have a script for each object that holds an array of other objects that are touching it. Since you’d only add to the array in OnCollisionEnter and remove from it in OnCollisionExit, I can’t imagine that it would be slow.