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