The Problems of Enemy AI in a Multiplayer Game


author: Alejandro Morales


During the development of Luddite, we as a team decided to implement pear-to-pear networking for multiplayer. Multiplayer was part of the C feature list but it was recommended for us to start development with multiplayer in mind if we wanted to implement it. So when we started to test out our prototype with multiple clients we started to experience a couple of bugs, especially with the enemy that we didn't have when debugging with a single player.  The main problem that we found was when the client went into aggro range of the enemy instead of chasing the player that aggroed him the enemy will chase and attack the host of the server no matter how far he is from the enemy. This is a problem because for testers that are on the client-side of the server it will feel like he's just a spectator that cant really interacts with the enemy in any way.

After doing some debugging it came to my attention that none of the tasks created for the enemy were networked meaning that when getting the location of the player it defaulted to player 1; the host. The problem was just one line of code that got the player's location because one of the parameters for the function was the player index and that defaulted to the host. I had to create a service that would loop through the number of players on the server check every player's distance to the enemy and return the closest player. This service was then added to the enemy AI's behavior tree so now every time the enemy sensed a player it will also get the correct player and pass that information to the rest of the tasks. There are still a few problems with the enemy one being that animations are not networked to the clients and cant do damage to the enemy. We are working hard to fix all of these fixes as soon as possible so we can have a playable prototype as soon as possible.

Leave a comment

Log in with itch.io to leave a comment.