Multiplayer Development Challenges

When a single player project goes to multiplayer, a bunch of assertions that could be made before cannot be made anymore such as:

  • An enemy will never move after it’s dead.
  • An enemy will never take damage after it’s dead.

To go from single player to multiplayer, members of the party relinquish their right to move the enemies, and allows the server or host to determine the enemy movements. We are also keeping track of the enemy HP locally to apply any damage the player does to that enemy. Because of the networking delays, this means we might be applying movement data from the server at the same time the enemy HP goes below 0. The movement animation may then play, replacing the death animation, and now the enemy with 0 HP stays visible on the floor. This is avoided by adding checks for the HP while applying enemy movement.

Another issue with asynchronous application of movement due to network delays is that an enemy can take damage after it’s dead. Normally this is impossible, so some checks weren’t in place, specifically getting rewards for killing an enemy after attack it and its HP reaching 0. Now I need to check if that enemy’s HP is already 0 before applying the damage and rewarding the player with its drops.

These are just a couple interesting examples of that I’ve ran into while implementing multiplayer.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *