Actor的Role和RemoteRole属性
Role:网络中扮演的角色类型
RemoteRole:远程连接的作用类型
Role_Authority: 权威
Role_SimulatedProxy: 模拟代理
Role_AutonomousProxy: 自主代理
Server(玩家A):
A,B,C的身份为:
Role: Role_Authority
RemoteRole: ROLE_SimulatedProxy
Client1(玩家B):
A1的身份为:
Role: ROLE_SimulatedProxy
RemoteRole: Role_Authority
B1的身份为:
Role: Role_AutonomousProxy
RemoteRole: Role_Authority
C1的身份为:
Role: ROLE_SimulatedProxy
RemoteRole: Role_Authority
Client2(玩家C):
A2的身份为:
Role: ROLE_SimulatedProxy
RemoteRole: Role_Authority
B2的身份为:
Role: ROLE_SimulatedProxy
RemoteRole: Role_Authority
C2的身份为:
Role: Role_AutonomousProxy
RemoteRole: Role_Authority
注:
模拟代理为防止传送丢失或提高效率而进行的根据之前的速率来模拟的模式;自主代理一般时本地playerController控制的Actor,会接受真人的输入来弥补数据的不足。
Actor 及其所属连接
注:
1.每个连接都有一个playerController.
2.actor最外围的所有者的连接则为actor所属的连接,动态生成时默认为spawn时设置的owner(默认是创建者)。注意:原本在场景中的actor默认为没有owner!
3.actor必须处于连接中才可以调用非广播的RPC。
4.连接所属用来确定actor复制和调用RPC时知道在哪个客户端执行。
从服务器调用的 RPC
Actor 所有权 |
未复制 |
NetMulticast |
Server |
Client |
Client-owned actor |
在服务器上运行 |
在服务器和所有客户端上运行 |
在服务器上运行 |
在 actor 的所属客户端上运行 |
Server-owned actor |
在服务器上运行 |
在服务器和所有客户端上运行 |
在服务器上运行 |
在服务器上运行 |
Unowned actor |
在服务器上运行 |
在服务器和所有客户端上运行 |
在服务器上运行 |
在服务器上运行 |
从客户端调用的 RPC
Actor 所有权 |
未复制 |
NetMulticast |
Server |
Client |
Owned by invoking client |
在执行调用的客户端上运行 |
在执行调用的客户端上运行 |
在服务器上运行 |
在执行调用的客户端上运行 |
Owned by a different client |
在执行调用的客户端上运行 |
在执行调用的客户端上运行 |
丢弃 |
在执行调用的客户端上运行 |
Server-owned actor |
在执行调用的客户端上运行 |
在执行调用的客户端上运行 |
丢弃 |
在执行调用的客户端上运行 |
Unowned actor |
在执行调用的客户端上运行 |
在执行调用的客户端上运行 |
丢弃 |
在执行调用的客户端上运行 |