2: Unreal Engine network Architecture: Replication

Source: Internet
Author: User

The main function of the Unreal Engine's network architecture is to keep the information of the server and client synchronized by replication actor,variable and function. Each class of Unreal has a copy statement replication{}. The variables and functions can be duplicated in this block.

This is a copy of the statement in the Playerreplication

Replication{ //服务器应该发送到客户断的数据。 if ( bNetDirty && ( Role == Role_Authority ) ) Score, Deaths, bHasFlag, PlayerLocationHint, PlayerName, Team, TeamID, bIsFemale, bAdmin, bIsSpectator, bOnlySpectator, bWaitingPlayer, bReadyToPlay, StartTime, bOutOfLives, UniqueId; if ( bNetDirty && ( Role == Role_Authority ) && !bNetOwner ) PacketLoss, Ping; if ( bNetInitial && ( Role == Role_Authority ) ) PlayerID, bBot;}

In the code above:
-bnetdirty indicates that a value in the variable has changed before replication occurs.
The-bnetinitial should always be true.
-True if the actor owner is the Playercontroller of the current client.

The replication module above defines the data that can be sent from the server side to the client in this actor, so that it can save a lot of bandwidth by selecting only a few parts for transmission. You can also take the part of network programming out of the code and look at it.



  1. Variable copying
Typically, a variable is sent to the client by the server, but there are a few cases where the data is returned from the client to the server side.for replication from the client to the server, this operation must be done in the client's Playercontroller!
Variable replication is always executed at the end of each update, and is reliable.

  
   2. Function copying
Although each function will always be performed in a single player game, it is not necessarily in the online game. For example, the function of the buff particle playing under the foot can only be seen for itself, while other players do not need to see it. Because of the problem of function copying and variable assignment sequencing, you have to consider that the copied function contains the variable that is to be copied, and you can copy it as a parameter to the function.
function replication can have unreliable,


   3. Simulation

Every function on the server is executed, unless it is sent from the client. On the client side, each function has a origin, either a copy function from the server to the client, an event function, or an EXEC function.
For the simulated function, it is intended to give the client support for functions that are close to the actor's actual performance and are called by both server and client. Given a projectile impact wall, this function can be set to simulated because the client can predict the occurrence of this event. This reduces unnecessary network transmission delays that are replicated from the server to the client. Most postbeginplay are also the case, where the actor in the client will initialize the dish itself.

 

  about optimizing and improving performance:
For the network design, we always want to think that the player to improve the low-latency game services for the purpose, so in the network programming should pay attention to a few principles and content:
-Minimize the number of replication actors
-Minimize updates per actors at tick: Minimize the number of relevancy actors (relevancy in the next section)
-Avoid unnecessary bnetdirty.

-Avoid unnecessary actor Spawn on the server side, such as exploding blood particles, so that the server-side players can see.
-Avoid some relevancy that are not related to gameplay, (well, here is the relevancy, which means that sometimes some actors are far from you and will not be in the camera and affect you.) That's when you don't need to do network synchronization for these actors. Bandwidth consuming)
-The number of EXEC function is minimized as far as possible
-In short, keep the following principles: 1. Keep the relevant acto of each client to a minimum
-Reduce the number of properties per update
-Reduce the number of transmit packets

Unzip devnettraffic to view the attribute records for all copied actors. Stat net to view the corresponding network status information.


  



2: Unreal Engine network Architecture: Replication

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.