Hi, I would like to have a variable to be replicated to OwnerOnly or to Everyone based on a bool (IsContainer) set on Blueprint Defaults. I did this in .cpp :
void UAC_Inventory::GetLifetimeReplicatedProps(TArray< FLifetimeProperty >& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
if (IsContainer)
{
DOREPLIFETIME(UAC_Inventory, Slots);
UE_LOG(LogTemp, Error, TEXT("Is Container"));
}
else
{
DOREPLIFETIME_CONDITION(UAC_Inventory, Slots, COND_OwnerOnly);
UE_LOG(LogTemp, Error, TEXT("Is not Container"));
}
}
It seems that the bool IsContainer is set AFTER the function GetLifetimeReplicatedProps, so it always return false (maybe because it’s set in Blueprint Defaults).
I thought about making a c++ child class and Override GetLifetimeReplicatedProps, so Slots is replicated to OwnerOnly on Parent, and replicated to everyone on child class. Is it correct to do this?