Currently I'm using A* and a raycasting algorithm to determine the path an entity (Player) should take to get close enough to the enemy (Enemy). The player has an attack range (it's illustrated around the enemy to show how close the player has to get to the enemy in order to attack it).
This works pretty well, but as soon as I add tiles that prevent entities from moving from them, but allows them to attack through them (imagine a river).
Using my current implementation the player entity takes the purple route to attack the entity, but I want it to take the yellow path.
I came up with the following, but this is highly inefficient:
- Mark the tiles around the enemy (cyan circle), which are in line of sight to the enemy (raycasting) as possible destinations
- Run the pathfinding algorithm to find which one of those destinations is the closest to the player
I know A* is good for finding a single destination and Dijkstra is better for multiple destinations, but since I already got this working with A* I wanted to know if it's possible to achieve this is an efficient manner.
Side question: how are the tiles where you cannot walk through, but can shoot through called in the industry? I know the wall likes entities are mostly called "solids".