hi everyone
i am trying to make a custom c++ playerstate class replication working
UCLASS(Blueprintable)
class AMyPlayerState : public APlayerState
{
GENERATED_BODY()
public:
AMyPlayerState();
UPROPERTY(ReplicatedUsing = OnRep_TeamIndex, BlueprintReadWrite)
int32 TeamIndex;
UFUNCTION()
void OnRep_TeamIndex();
UFUNCTION(BlueprintImplementableEvent, Category = "Team")
void OnBPTeamIndexChanged(int32 NewTeamIndex, int32 OldTeamIndex);
protected:
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
private:
// Previous value of TeamIndex (not replicated)
int32 PreviousTeamIndex;
};
AMyPlayerState::AMyPlayerState()
{
bReplicates = true;
SetReplicates(true);
TeamIndex = -100;
PreviousTeamIndex = -100;
}
void AMyPlayerState::OnRep_TeamIndex()
{
OnBPTeamIndexChanged(TeamIndex, PreviousTeamIndex);
PreviousTeamIndex = TeamIndex;
}
void AMyPlayerState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(ACrazyPlayerState, TeamIndex);
}
then i derive a blueprint class from it,
if i change the teamindex property on the server the value is not replicated !
on the other side i have tested to inherit from a bluerprint playerstate class and everything worked just fine .
any idea on what’s going on please