I have a small game where multiple players connect to a server. The server handles all enemy movement calculations.
In the game, a player can build walls. The walls are aligned to a grid. The players and enemies are not, but their current position can be approximated to a grid position. Enemies attempt to reach and attack the player. If they can’t reach the player, I want them to attack the wall that is blocking them.
Currently, I have steering behaviours implemented that allow the enemy to reach the player with minimal ai. The problem I am having trouble sorting out is how to handle a player that is unreachable (eg walls completely enclose the player). The desired behaviour is for the enemy to say:
- Hey, this player is unreachable.
- This wall is in my way.
- Lets target this wall instead.
I feel like running a pathfinding algorithm for every enemy on every update will cause performance issues. I can’t use a navmesh since the environment changes during the game.
What is the best method to handle this?