Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

UE 网络编程

1. C++中在哪个阶段设置Actor replicated?

在构造函数中,直接设置,会在服务器上执行。无需HasAuthority()的判断,因为此时网络角色的变量还没有更新。

AMyActor::AMyActor()
{
	SetReplicates(true);          // 同步Actor的存在
	SetReplicateMovement(true);   // 同步位置/旋转/速度
}

2. Local Role 和 Remote Role 表格

机器Actor类型LocalRoleRemoteRole备注
Server (Listen)所有 ActorAuthoritySimProxyGetRemoteRole() 本地读取统一返回 SimProxy
Client自己的 PawnAutonomousProxyAuthorityIsLocalController()=true
Client其他人的 PawnSimProxyAuthority
Client非玩家 ActorSimProxyAuthority

3. Rep Notifies

在蓝图中,服务器和client都执行。在C++中,只有Client执行。

4. 关于PreReplication怎么用