GameMode只有服務端有,適合寫遊戲邏輯。PlayerController每一個客戶端擁有一個,並擁有主控權。GameState在服務端同步到全端。
CLIENT生成的Actor對其有Authority。
http://api.unrealengine.com/INT/Gameplay/Framework/GameMode/index.html
簡單來說 須要同步的操做寫到Server,不須要同步的操做寫到Clienthtml
Replicated 複製模式
RepNotify:會建立一個變量改變通知的函數
屬性複製條件介紹:http://api.unrealengine.com/CHN/Gameplay/Networking/Actors/Properties/Conditions/index.htmlc++
對這個ACTOR是否有主控權限,Client對本身擁有的Pawn有Authority,Client生成的Actor也擁有Authorityapi
給一個Actor設置擁有者,用於網絡複製條件判斷。源碼裏服務器
負責Destroy此Actor的Actor網絡
UPROPERTY(ReplicatedUsing=OnRep_Owner)//屬性複製,改變時調用函數onRep_Owner AActor* Owner;
//.h UFUNCTION(NetMulticast, reliable) void Fun2(); //.cpp void Cls1::Fun2_Implementation() {//這裏要加_Implementation() }//Fun2函數的實現被UHT(UnrealHeaderTool)使用了
UObject::CallFunctionByNameWithArguments
UEngine::SetClientTravelide
若是爲真,則該角色(網絡同步)僅與其全部者相關。若是在播放期間更改此標誌,則全部非全部者信道都須要顯式關閉。
若是這個Actor服務器只想讓Actor的全部者獲得同步信息,或者說,不想讓整個地圖的人都知道Actor的信息,只想讓距離Actor的必定範圍的人獲得同步,又或者說,只想讓某些付費玩家獲得同步信息,怎麼辦?這時有一個叫「network relevant」的概念,也就是說,只有當一個Actor對於服務器是net relevant的時候,服務器纔會同步信息給他。好比說:只想讓Actor的全部者獲得信息,咱們能夠設置Actor::bOnlyRelevantToOwner變量爲true。函數
If true, this actor is only relevant to its owner. If this flag is changed during play, all non-owner channels would need to be explicitly closedthis
始終與網絡相關(覆蓋OnlyRelevantToOwner).net
Always relevant for network (overrides bOnlyRelevantToOwner).code
若是是真的,複製移動/位置相關的屬性,也必須是演員來複制。
If true, replicate movement/location related properties. Actor must also be set to replicate.
加載於地圖加載期間
This actor will be loaded on network clients during map load
若是Actor有擁有者,調用業主的IsNetRelevantFor,GetNetPriority
覆蓋IsNetRelevantFor,可自定義關聯更新
If actor has valid Owner, call Owner's IsNetRelevantFor and GetNetPriority
If true, this actor will replicate to remote machines
Dormancy setting for actor to take itself off of the replication list without being destroyed on clients.
休眠設置,使演員從複製列表脫身而不被客戶端損壞
最大距離的平方, 從客戶視口來看, 這個演員是相關的, 將被複制。
Square of the max distance from the client's viewpoint that this actor is relevant and will be replicated.
How often (per second) this actor will be considered for replication, used to determine NetUpdateTime
How often (per second) this actor will be considered for replication, used to determine NetUpdateTime
Priority for this actor when checking for replication in a low bandwidth or saturated situation, higher priority means it is more likely to replicate
Velocity Quantization Level 量子化等級,把float後面的小數Round(四捨五入)
對於每個經過最初檢測的actor, 會調用AActor::PreReplication。
經過AActor::PreReplicatoin決定是否想要爲鏈接複製這個屬性。經過DorepLifeTime_Active _Override
所有條件經過會加入到ConsiderList
經過調用UChannel::ReplicateActor對Actor進行復制
若是是channel打開後的第一次Update那麼須要特殊初始化一些信息
若是該連接擁有這個actor,則設置actor::ENetRole=ROLE_AuonomousProxy,不然actor::ENetRole=Role_SimulatedProxy
http://www.cnblogs.com/Leonhard-/p/6511821.html
https://blog.csdn.net/xiejihao/article/details/80264148#commentBox
http://www.javashuo.com/article/p-ppohxivk-md.html