Problem with replication, gets error with GetLifetimeReplicatedProps

I get the following error when I try to use this line of code:

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, ReplicatedUsing = HeadScaleUpdated, Category = Pawn)

The problem is with the ReplicatedUsing keyword. I have had this exact problem with the “replicated” keyword on a UPROPERTY before. What should I do to resolve this error?

Error 24 error LNK2001: unresolved external symbol "public: virtual void __cdecl AIntegratedCharacterNoAI::GetLifetimeReplicatedProps(class TArray<class FLifetimeProperty,class FDefaultAllocator> &)const " (?GetLifetimeReplicatedProps@AIntegratedCharacterNoAI@@UEBAXAEAV?$TArray@VFLifetimeProperty@@VFDefaultAllocator@@@@@Z) C:\Users\sgjkbd\Desktop\ProjectAngelis\ProjectAngelis\Intermediate\ProjectFiles\IntegratedCharacterNoAI.cpp.obj ProjectAngelis

You need to define the GetLifetimeReplicatedProps function in your CPP file.

You replicate UPROPERTYs with Replicated or ReplicatedUsing, and then also add them to GetLifetimeReplicatedProps.

void AIntegratedCharacterNoAI::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);

	DOREPLIFETIME(AIntegratedCharacterNoAI, YourVariableNameHere);
}

Also, don’t forget to #include “UnrealNetwork.h” in your CPP. And in your main .h file change #include “EngineMinimal.h” to "#include “Engine.h”.

2 Likes

that does not help

1 Like