- Home /
Grid matching issue
Summary of question: When a cube is selected on the graph I would like the surrounding cubes with the same colour deleted but am having problems doing this repeatedly.
What I am currently doing: I have created a grid layout with different coloured cubes, stored in a multi-dimensional array. Each colour has an ID that is assigned during instantiation. When I click on the cube in the red box it checks its horizontal and vertical neighbours to see if their ids match the selected cubes.
What I am having issue with: When you check the red box cubes neighbours , i would like the neighbours to do the same check until all the matching ids have been identified (green line). These will need to be stored/deleted after this check has done. However I am having issues in a formula to check the surrounding cubes. I have a “CheckNeightbour” method however if I call this method when a cube with the correct ID is found, i am getting a StackOverflow exception as I am calling a method within that method.
Does anyone know/can think of a formula to help me with this?