Hello, i’m trying to spawn on the server the inventory for every character, but if i do the spawn code on PostInitializeComponents() he doesn’t replicate for the characters. I started investigating the problem and i noticed that GetLifetimeReplicatedProps() is executed after PostInitializeComponents() so i tried putting the spawn code on BeginPlay() and it started working. The Shooter Game sample uses PostInitializeComponents, so i’m wondering what i’m doing wrong.
UPROPERTY(Transient, Replicated)
class AInventory * Inventory;
void AMyCharacter::PostInitializeComponents()
{
Super::PostInitializeComponents();
if (Role != ROLE_Authority)
return;
Inventory = GetWorld()->SpawnActor<AInventory>(AInventory::StaticClass());
}
void AMyCharacter::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME_CONDITION(AMyCharacter, Inventory, COND_OwnerOnly);
}