Detecting nodes near the hit node

Hello all,

I’m struggling to figure out the best way to handle this scenario. Basically what I have now is a scene with a sphere made of cubes like this:

At the end of the day I just have one parent node that is the large sphere, and then dozens of child nodes that are the squares in the image above. However the big difference between what I have and this image is that behind all of these cubes is another colored triangle-cubeish shape that keeps going until the center.

The code I have working now allows a user to click on a color and it will alter all of the cubesin the scene that are that color.

As you can see in this image there are two yellow cubes in the lower right corner next to each other, what I want to happen is that when you click on one of those yellow cubes it will search all of the other cubes around it in any direction (including the z-index, horizontal, and vertically) and only change the colors of those cubes that are touching the hit cube.

I’m not asking for anyone to write my code for me, but I’m at a loss with the best way to even approach solving this problem.

Hi @maxshuty, feel free to share some your code that you’ve tried and or you are having trouble with that way we can have a better idea of what you are trying to solve. I don’t have any coding examples to share unfortunately. As for the approach, I would start with thinking about the action that occurs after clicking on the yellow cube. You want it to search in all directions. So maybe consider creating a statement that checks in all directions from the point the user touched and only effect the cubes are touching the hit cube. Hope this points you in the right direction.


This topic was automatically closed after 166 days. New replies are no longer allowed.