Let's talk

RSExamplePlayerState.cpp

Examples/RSExamplePlayerState.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 "RSExamplePlayerState.h"
4
5#include "AbilitySystemComponent.h"
6#include "RSExampleAttributeSet.h"
7
8ARSExamplePlayerState::ARSExamplePlayerState()
9{
10 AbilitySystem = CreateDefaultSubobject<UAbilitySystemComponent>(TEXT("AbilitySystem"));
11 AbilitySystem->SetIsReplicated(true);
12
13 // Mixed: the owning client gets full effect info (needed for prediction),
14 // everyone else gets the minimal tags and cues. Use Full only for single-player.
15 AbilitySystem->SetReplicationMode(EGameplayEffectReplicationMode::Mixed);
16
17 // Created as a subobject of the owner, so the ASC finds and replicates it.
18 Attributes = CreateDefaultSubobject<URSExampleAttributeSet>(TEXT("Attributes"));
19
20 // The engine default for PlayerState is very low; abilities and attributes
21 // replicate through this actor, so a low rate shows up as input lag.
22 // Lyra uses 100. Profile before going lower.
23 SetNetUpdateFrequency(100.f);
24}

Still desyncing in packaged builds?

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