In the client of the online game, when I put an Actor pointer as a property of a UObject, after the UObject is synchronized, the Actor pointer is null, but the Actor is synchronized to the client.
void UReplicatedTestComponent::InitComponent(AMyPlayerController* NewOwner)
{
if(!IsValid(NewOwner))
{
return;
}
if(IsValid(ComponentOwner) && NewOwner->IsLocalController() )
{
UE_LOG(LogTemp,Warning,TEXT("Controller is Replicated"));
}
else
{
ComponentOwner = NewOwner;
}
if(GetNetMode() >= NM_Client)
{
UE_LOG(LogTemp,Warning,TEXT("Current is Client Run InitComponent"));
if(ObjectAry.Num()>0 && IsValid(ObjectAry[0]->TestActor))
{
ObjectAry[0]->TestActor->CreateClientTestActor(Cast<ADedicatedTestCharacter>(NewOwner->GetCharacter()));
}
return;
}
UReplicateTestObject* TempObject = nullptr;
TempObject = NewObject<UReplicateTestObject>(ComponentOwner,TestObject_T);
if(IsValid(TempObject))
{
ObjectAry.AddUnique(TempObject);
TempObject->InitObject(this,true);
}
}