What is an efficient method for procedural pathfinding over a network?

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?

You have your grid allready. Use it and run A* on it to find paths. You only have to recalculate a path when A. the path goal changes or B. a wall is set or removed. On a grid A* isnt that expansive anyway and you could ofcourse spread the path calculations over serval frames. Its easy to implement A* your self, no exotic math required. :slight_smile: There cant be a diffrent way to check, if someon is reachable, you always have to try finding a path.