Find Hexagonal Tiles Within Certain Range
I have a hexagonal flat-top tilemap with a player on it. The player can move to some of tiles and I have a hashset of the vector3int positions of the tiles that the player can move to. The player also has an array of integers that are the ranges they can attack and I want to get a hashset of all the tiles that are within their attack range of the tiles they can move to.
I actually have a working way to get all these tiles but it takes a long time once the move or attack range numbers are more than around 5. My method is going through each tile the player can move to and recursively calling a method on all its adjacent tiles and subtracting 1 from the max attack range each time, then checking if the distance from the starting tile is one of the player's range integers. Then repeat this until the range reaches 1. I also made sure that the method isn't called on the same tile multiple times from the same starting tile but it still seems to take a long time.
I just need a more efficient way to find the tiles within the range. Help is appreciated!
Your answer
Follow this Question
Related Questions
Save game - Tile based game 0 Answers
Hexagon grid check for specific tile 0 Answers
Move Object around a platform of tiles 0 Answers
Tilemap grid for hexagon tiles 0 Answers