I’m working on a game that starts with a 3x3 grid of nine cubes as the gameboard. Throughout the game, players can add sets of three cubes as a turn, just about anywhere that is adjacent to another cube - on the x, y and z axis and in no uniform way. Over time, the gameboard will evolve with cubes going in all directions from random places.
For each cube, I need to know how many cubes are touching a side, edge or corner. In theory, a single cube could have 26 other cubes touching it - in a 3x3x3 grid of 27 cubes, the center cube would be touching the 26 others.
Does anyone have any thoughts on the best way to approach this?
I attempted to use colliders with triggers on each cube that returned which colliders were overlapping. From there, a manager script on each cube would keep track of how many of the potential 26 touching cubes were in existence. I got inconsistent results and am now questioning using colliders like that.
Any tips or thoughts are appreciated. I know this concept can’t be unique and must be used in games with real-time building.