Hello, I have a quick replication question.
I set up the following function inside my gamemode, It generates a new APRT_Loadout type variable and sets the value of CurrentLoadout on every player controller
void APRT_GameMode::StartNewRound()
{
Super::StartNewRound();
//get a loadout and set it on controller
APRT_Loadout* ChosenLoadout = LoadoutGenerator->PickLoadout();
if(ChosenLoadout)
{
for (FConstPlayerControllerIterator Iterator = GetWorld()->GetPlayerControllerIterator(); Iterator; ++Iterator)
{
APRT_PlayerController* Controller = Cast<APRT_PlayerController>(*Iterator);
if(Controller) Controller->SetCurrentLoadout(ChosenLoadout);
}
}
}
void APRT_PlayerController::SetCurrentLoadout(APRT_Loadout* New)
{
CurrentLoadout = New;
}
The CurrentLoadout inside the playercontroller is replicated using a rep notifier:
UPROPERTY(ReplicatedUsing=OnRep_CurrentLoadout)
APRT_Loadout* CurrentLoadout;
void APRT_PlayerController::OnRep_CurrentLoadout()
{
if (GetShooterHUD()) GetShooterHUD()->LoadoutSpawned(CurrentLoadout);
}
However, the variable never replicates back to the client, the rep notifier of course doesn’t fire as well.
My GetLifetimeReplicatedProps is all set too:
void APRT_PlayerController::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(APRT_PlayerController, CurrentLoadout);
}
Any ideas why this happens? Thanks!
EDIT: I changed my DOREPLIFETIME for:
DOREPLIFETIME_CONDITION_NOTIFY(APRT_PlayerController, CurrentLoadout, COND_None, REPNOTIFY_Always);
and the rep notify happens but it replicates a nullptr