Determining what information should be sent to the server with the purpose to replicate a true real-time multiplayer experience is the foremost step in the direction of designing effectual networking communications. Of course, there are many key facets to consider before a game developer actually gets there.
Here in this article, we will be discussing a few important topics that are important in Multiplayer Game Development. We will cover-
- How lag affects games?
- Why is it important to address lag?
- And a few lag compensation techniques
What is Lag Compensation?
Before actually moving to lag compensation, let’s understand a few basic concepts, which eventually will help in dealing with lag compensation issues:
- Round trip time or the RTT – As the name suggests, round trip time is the amount of time a packet of information takes to travel from client to server and back to the client. Here the processing times are not considered.
- Lag – Again, the name says it all. Lag is the time delay that occurs when the player sends the “action” and when he/she receives the “reaction” from the server. Here the action can be - jump, shoot, duck, etc. and the reaction from the server can be – avoid the hit, shoot the bullet, etc.
- Lag Compensation – The role of lag compensation is to minimize the discrepancy caused by the lag in the response time and offer uninterrupted gameplay. Depending on the type of game, this technique can be applied either at the server level or at the client level.
These were a few basic definitions; however, it is important to understand both client-side lag compensation and server-side lag compensation if you want to learn Multiplayer Game Development at its best. Let’s explore each of them one by one –
Client-side lag compensation
With the aim to solve lag issues from the client, the developer could work by means of an interpolation system for setting the game characters. The approach aims at delivering simulation from the clients, which is a few steps behind what is received from the server. For example – When a server sends data, like – the position of an enemy – the client simulation won’t be updated instantaneously, but it counterbalances seeing the lags from other clients.
This can even be extrapolated in a manner that – the client envisages the next possible position of the character and correspondingly revises the position when the updated data is received from the server. This also means that the client presumes that if a character is moving in a specific direction, the same will keep moving in that particular direction.
Server-side lag compensation
The client-side lag compensation solutions cover a very limited number of situations and for many developers, these solutions do not work for most of their multiplayer gameplay experiences. For such situations, server alternatives are some better options that aim at achieving better lag compensation. However, just keep in mind that these solutions can lead to complications as well.
There are three ways of compensating lag from the server-side-
- Deterministic simulation – This solution aim at handling all the simulation in the server, based on the inputs client send to the server. This way similar lag is experienced on all the clients, thus reducing the compensation issues. The negative aspect of this approach is that it affects the player’s interaction with the game, resulting in slowing down the player’s perception of the response time. Reason being – the user sends the input, the server receives the data, sends back a response – this wastes time, causing lag. Quite evident to the player.
- Reliable protocols – Another approach is to use a reliable protocol, like TCP – which ensure reliable and correct ordered data packet delivery. This ensures simple and quick processing both on the client side and on the server side. For more advanced networking, one can even opt for sophisticated, custom game protocol with lighter encapsulation for reducing the inherent overhead bracketed with TCP.
- Send all simulation state – In this very solution, the total game state is shared. However, it should be ensured that only one client is allowed to modify the game-state at any given point, that the state is atomic in operations. Doing this will ensure that both client (or even clients) and the server will have the latest game versions at all times and hence can perform actions accordingly.
This was all for this article, for more information on the topic and where to learn Multiplayer Game Development,
Visit http://mages.edu.sg/