I need to come up with a better way to test for adjacency in a grid environment. Imagine that the blue is water, the green is land, and the red dot is a character. What I need to do is efficiently return a list of Vector positions of all grid tiles for the "island" that the character is on.
I have attempted to do this with raycasts using the following procedure.
-raycast at all of the immediately adjacent nodes surrounding the player.
-if (hit == land) then add hit to adjacent list.
-raycast at all immediately adjacent grid cells around each of the previous hits on land. (if they have not already been tested)
-if (hit == land) add to the adjacent list.
-loop until no more hits on land.
this seems to work okay, but is not very fast. If possible I need to maintain the raycasting because the levels are randomly generated at run time.