- Home /
Grid/Tile-Based: Iterating through all tiles around a character
I'm scripting my AI behavior and I want an AI actor to first check if there is any tile that provides cover from the player actor's ranged attacks. The tiles all have coordinates of multiples if 1 on all axis.
So effectively I'd need to iterate through all tiles in certain radius (lets say, 5) around the AI actor and check each one for cover (which isn't part of my question).
Since the tiles are no gameobjects or stored in some way, I am trying to find an algorithm that goes through all coordinates inside the radius of 5, but I don't know where to start. Any pointers? I'm not asking for complete scripts, just a little nudge ;)
It'd probably be best if the iteration is in the form of a "snail" drawing around the actor's position, so once a suitable tiles is found, the loop can be ended prematurely.
Your answer
Follow this Question
Related Questions
How to create a rotating tiles with walls on edges of tiles? 0 Answers
Unity 2D tiles and grid 1 Answer
Grid Based Question 0 Answers
Programming an isometric (top down) grid 0 Answers