注意,DOREPLIFETIME需要头文件: Net/UnrealNetwork.h
NETWORK TIPS AND TRICKS
https://www.unrealengine.com/blog/network-tips-and-tricks
BASIC PROPERTY REPLICATION
I wanted to talk about a few tips that are good to know about when dealing with replicated properties in native code.
The full explanation of how to replicate a property is somewhat out of the scope of this article, but I can quickly go over the basics here.
To replicate a property you need to do a few things:
In the header of the actor class where the property is defined, you need to make sure you have the ‘replicated’ keyword as one of the parameters to the UPROPERTY declaration:
class ENGINE_API AActor : public UObject
{
UPROPERTY( replicated )
AActor * Owner;
};
In the implementation of the actor class, you need to implement the GetLifetimeReplicatedProps function: