Let's talk

RSExampleAttributeSet.cpp

Examples/RSExampleAttributeSet.cpp Raw Download ZIP

Click a line number to link it. Shift-click to select a range.

1// Copyright (c) 2026 Reignance Studios. MIT License, see LICENSE.
2
3#include "RSExampleAttributeSet.h"
4
5#include "Net/UnrealNetwork.h"
6
7void URSExampleAttributeSet::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
8{
9 Super::GetLifetimeReplicatedProps(OutLifetimeProps);
10
11 // REPNOTIFY_Always: fire OnRep even when the server value equals the
12 // client's predicted value, or the client never confirms its prediction.
13 DOREPLIFETIME_CONDITION_NOTIFY(URSExampleAttributeSet, Health, COND_None, REPNOTIFY_Always);
14 DOREPLIFETIME_CONDITION_NOTIFY(URSExampleAttributeSet, Stamina, COND_None, REPNOTIFY_Always);
15}
16
17void URSExampleAttributeSet::OnRep_Health(const FGameplayAttributeData& OldValue)
18{
19 GAMEPLAYATTRIBUTE_REPNOTIFY(URSExampleAttributeSet, Health, OldValue);
20}
21
22void URSExampleAttributeSet::OnRep_Stamina(const FGameplayAttributeData& OldValue)
23{
24 GAMEPLAYATTRIBUTE_REPNOTIFY(URSExampleAttributeSet, Stamina, OldValue);
25}

Still desyncing in packaged builds?

Free code fixes one symptom. A Diagnostic finds the cause across your project in two days.