- Home /
Question by
ic3t3a2000 · Mar 12, 2013 at 09:49 PM ·
instantiateraycastgrid
how to tell if fence encloses area
I have a tile grid. I am placing 'fence' objects on the grid. I am casting a ray to determine which grid tiles have a fence object on them.
The goal of the game is to surround objects with a fence. Once they are surround then they are "captured". However I am having trouble coming up with a system that can accurately detect if a gameobject is surrounded by fence objects.
Anyone know how I might be able to do this accurately?
Comment
Answer by Graham-Dunnett · Mar 12, 2013 at 10:14 PM
Try a flood fill algorithm, and see if you can reach the edge of the grid.