protected:
UPROPERTY(ReplicatedUsing = OnRep_CurrentHP, Transient, VisibleInstanceOnly, Category = Stat)
float CurrentHP;
protected:
virtual void ReadyForReplication() override;
virtual void GetLifetime(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
UFUNCTION()
void OnRep_CurrentHP();
구현부
void UABCharacterStatComponent::UABCharacterStatComponent()
{
SetIsReplicated(true);
}
void UABCharacterStatComponent::ReadyForReplication()
{
Super::ReadyForReplication();
}
void UABCharacterStatComponent::GetLifetime(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetime(OutLifetimeProps);
DOREPLIFETIME(UABCharacterStatComponent, CurrentHP);
}
void UABCharacterStatComponent::OnRep_CurrentHP()
{
OnHpChanged.Broadcast(CurrentHP);
if (CurrentHP <= KINDA_SMALL_NUMBER)
{
OpHpZero.Broadcast();
}
}