MotionAttributeSet
Default GAS AttributeSet providing movement and stamina attributes with automatic CharacterMovementComponent synchronization.
Requirements
- MotionPlayerState configured in GameMode
- Gameplay Ability System (GAS) initialized
- Character with standard
UCharacterMovementComponent - No additional Gameplay Effects required - attributes are defined here
Installation
- MotionAttributeSet is automatically included with MotionPlayerState
- No manual setup required if using MotionPlayerState
- For custom setups, add to your AbilitySystemComponent:cpp
AbilitySystemComponent->AddAttributeSetSubobject<UMotionAttributeSet>(); - Default values are set automatically on initialization
To override the default values used in the AttributeSet, create a DataTable with Row Type AttributeMetaData.

Functionality
The AttributeSet manages character attributes and automatically syncs them with movement components.
Expandability
| Function | Description | Use Case Examples |
|---|---|---|
PostAttributeChange() | React to attribute changes | • Trigger UI updates • Apply additional effects • Handle prediction reconciliation |
PreAttributeChange() | Validate before changes | • Prevent invalid values • Add change conditions |
PostGameplayEffectExecute() | React to GE execution | • Log attribute changes • Trigger abilities |
GetLifetimeReplicatedProps() | Customize replication | • Add conditional replication • Change rep conditions |
Gameplay Attributes
Movement Attributes
| Attribute | Type | Default | Replication | Auto-Sync | Description |
|---|---|---|---|---|---|
| WalkSpeed | FGameplayAttributeData | 600.0 | OnRep_WalkSpeed | CMC->MaxWalkSpeed | Base walking speed for character movement |
| SprintSpeed | FGameplayAttributeData | 300.0 | OnRep_SprintSpeed | None | Sprint speed modifier (additive to WalkSpeed: 600 + 300 = 900 total) |
| JumpVelocity | FGameplayAttributeData | 420.0 | OnRep_JumpVelocity | CMC->JumpZVelocity | Jump velocity for character jump mechanics |
Stamina System Attributes
| Attribute | Type | Default | Replication | Clamping | Description |
|---|---|---|---|---|---|
| Stamina | FGameplayAttributeData | 5.0 | OnRep_Stamina | 0.0 to MaxStamina | Current stamina amount for sprint mechanics |
| MaxStamina | FGameplayAttributeData | 5.0 | OnRep_MaxStamina | None | Maximum stamina capacity |
| StaminaRegenRate | FGameplayAttributeData | 1.0 | OnRep_StaminaRegenRate | None | Stamina regeneration per second when not sprinting |
| StaminaDrainRate | FGameplayAttributeData | 1.0 | OnRep_StaminaDrainRate | None | Stamina consumption per second when sprinting |
ATTRIBUTE_ACCESSORS Macro
Each attribute automatically gets these accessor functions via the ATTRIBUTE_ACCESSORS macro:
// For each attribute (using WalkSpeed as example):
static FGameplayAttribute GetWalkSpeedAttribute(); // Get attribute reference
float GetWalkSpeed() const; // Get current value
void SetWalkSpeed(float NewValue); // Set new value
void InitWalkSpeed(float InitialValue); // Initialize valueUsage Examples
// Get current attribute values
float CurrentSpeed = AttributeSet->GetWalkSpeed();
float CurrentStamina = AttributeSet->GetStamina();
// Set attribute values (triggers PostAttributeChange)
AttributeSet->SetWalkSpeed(800.0f);
AttributeSet->SetStamina(3.0f);
// Initialize attributes (typically done once)
AttributeSet->InitWalkSpeed(600.0f);
AttributeSet->InitMaxStamina(10.0f);
// Get attribute references for Gameplay Effects
FGameplayAttribute WalkSpeedAttr = UMotionAttributeSet::GetWalkSpeedAttribute();
FGameplayAttribute StaminaAttr = UMotionAttributeSet::GetStaminaAttribute();Attribute Access
C++ Access
// Get attribute value
float CurrentSpeed = AttributeSet->GetWalkSpeed();
// Set attribute value (triggers sync)
AttributeSet->SetWalkSpeed(800.0f);
// Init from data table
AttributeSet->InitWalkSpeed(600.0f);Blueprint Access
Get Walk Speed from Attribute Set
├── Target: Motion Attribute Set
└── Return: Float (Current Walk Speed)
Set Walk Speed on Attribute Set
├── Target: Motion Attribute Set
└── New Value: 800.0Gameplay Effect Access
Gameplay Effect: GE_Motion_SprintSpeed
├── Modifiers
│ └── Attribute: MotionAttributeSet.WalkSpeed
│ ├── Modifier Op: Add
│ └── Magnitude: 300.0
└── Duration: InfiniteAutomatic Synchronization
The AttributeSet automatically syncs with CharacterMovementComponent:
WalkSpeed → MaxWalkSpeed
- Changes to WalkSpeed attribute update CMC MaxWalkSpeed
- Happens in PostAttributeChange
- Works for both server and client
WARNING
The WalkSpeed attribute syncs only to MaxWalkSpeed. The MaxWalkSpeedCrouched property is managed separately by the crouch component and is not controlled by attributes.
This is subject to change.
JumpVelocity → JumpZVelocity
- Changes to JumpVelocity attribute update CMC JumpZVelocity
- Instant synchronization
- Respects network authority
Implementation Detail
The sync to CharacterMovementComponent includes intelligent prediction handling. During client prediction, the system temporarily ignores server updates that would cause rubberbanding, ensuring smooth local gameplay.
Stamina System Integration
When MotionSprintingComponent uses stamina:
- Drains Stamina attribute while sprinting
- Regenerates Stamina when not sprinting
- Clamps between 0 and MaxStamina
- Triggers exhaustion at 0
Replication
All attributes are replicated with OnRep functions:
OnRep_WalkSpeed()- Syncs walk speed on clientsOnRep_SprintSpeed()- Updates sprint speedOnRep_JumpVelocity()- Syncs jump velocityOnRep_Stamina()- Updates stamina displayOnRep_MaxStamina()- Updates stamina maximumOnRep_StaminaRegenRate()- Updates regen rateOnRep_StaminaDrainRate()- Updates drain rate
Attribute Macros
The ATTRIBUTE_ACCESSORS macro provides:
GetWalkSpeed()- Get current valueSetWalkSpeed()- Set new valueInitWalkSpeed()- Initialize valueGetWalkSpeedAttribute()- Get attribute reference
Common Gameplay Effects
Sprint Speed Increase:
- Attribute: WalkSpeed
- Operation: Add
- Magnitude: +300 (uses SprintSpeed attribute value)
Crouch Speed Decrease:
- Attribute: WalkSpeed
- Operation: Add
- Magnitude: -200
Jump Boost:
- Attribute: JumpVelocity
- Operation: Multiply
- Magnitude: 1.5
Stamina Drain:
- Attribute: Stamina
- Operation: Add
- Magnitude: -1.0 per second
Performance Notes
- Attribute changes are optimized for frequent updates
- CMC synchronization happens only on value change
- Replication uses reliable RPCs for critical values
- Clamping prevents invalid states automatically
Client Prediction Handling
The AttributeSet includes advanced prediction logic for smooth multiplayer gameplay:
Local Prediction System
When Motion components (Sprint/Walk) apply speed changes on clients:
- Components set
bIsLocallyPredictingflag with predicted speed value - PostAttributeChange checks if client is actively predicting
- If server update matches prediction (within 1.0 tolerance), prediction state cleared
- If mismatch, client skips server update to avoid rubberbanding