Handling network synchronizations
When you played the multiplayer Pangaea game, you would have noticed some bugs; for example, if you attacked on the client side, the player’s server avatar wouldn’t attack. These bugs occurred because our single-player code didn’t handle multiplayer synchronizations.
Before writing multiplayer code, we want to emphasize that you must be very clear in your mind whether the code will be executed on the server side, the client side, or both the server and client sides.
To make Pangaea playable as a multiplayer game, we need to do the following:
- Notify player attacks with remote procedure calls (RPCs)
- Sync actor variables to clients with replications
- Update the character health bar with
RepNotify
- Process hits on the server
- Spawn fireballs on the server side
Let’s look at how we can implement all of these listed actions.
Notifying player attacks with RPCs
In Pangaea, a player’...