Download

Actor pointer not replicating

Hello Every one… I create an object on the server on the BeginPlay function something like this…


void APSE_LYFE_Character::BeginPlay()
{
	Super::BeginPlay();
	if (Role == ROLE_Authority)
	{
		InventroyPtr = GetWorld()->SpawnActor<APSE_LYFE_Inventory4_QuickSlots>(InventoryClass);
		InventroyPtr->SetOwningPawn(this);
		GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Blue, "Inv spawn");
	}
}

The InventoryPtr is set to replicate but its not replicating.



UPROPERTY(Replicated, Transient)
	class APSE_LYFE_Inventory4_QuickSlots* InventroyPtr;

I am trying to check if the pointer becomes valid on the client but it is not.

Try adding the below code to your cpp file:


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


    DOREPLIFETIME_CONDITION( APSE_LYFE_Character, InventroyPtr, COND_OwnerOnly );
}

Thank you… :slight_smile: Working on replication again after a few weeks and I had forgotten about that…