Let's talk

RSExampleAttributeSet.h

Examples/RSExampleAttributeSet.h 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// Example only: copy into your game module and rename the RSExample prefix.
3
4#pragma once
5
6#include "CoreMinimal.h"
7#include "AttributeSet.h"
8#include "AbilitySystemComponent.h"
9#include "RSExampleAttributeSet.generated.h"
10
11#define RS_ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \
12 GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \
13 GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \
14 GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \
15 GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName)
16
17UCLASS()
18class URSExampleAttributeSet : public UAttributeSet
19{
20 GENERATED_BODY()
21
22public:
23 UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_Health, Category = "Attributes")
24 FGameplayAttributeData Health;
25 RS_ATTRIBUTE_ACCESSORS(URSExampleAttributeSet, Health)
26
27 UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_Stamina, Category = "Attributes")
28 FGameplayAttributeData Stamina;
29 RS_ATTRIBUTE_ACCESSORS(URSExampleAttributeSet, Stamina)
30
31 virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
32
33protected:
34 // GAMEPLAYATTRIBUTE_REPNOTIFY keeps client prediction intact: it tells the
35 // ASC about the new server value so predicted changes are re-applied on top.
36 UFUNCTION()
37 void OnRep_Health(const FGameplayAttributeData& OldValue);
38
39 UFUNCTION()
40 void OnRep_Stamina(const FGameplayAttributeData& OldValue);
41};

Still desyncing in packaged builds?

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