Appearance
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 | Status in MotionAttributeSet |
|---|---|---|
PostAttributeChange() | React to attribute changes | Implemented - syncs to CMC |
PreAttributeChange() | Validate before changes | Base class - override in subclass |
PostGameplayEffectExecute() | React to GE execution | Base class - override in subclass |
GetLifetimeReplicatedProps() | Customize replication | Implemented - all attrs replicated |
Gameplay Attributes
Movement Attributes
| Attribute | Type | Default | Replication | Clamping | Auto-Sync | Description |
|---|---|---|---|---|---|---|
| WalkSpeed | FGameplayAttributeData | 600.0 | OnRep_WalkSpeed | Min: 0.0 | CMC->MaxWalkSpeed | Base walking speed for character movement |
| SprintSpeed | FGameplayAttributeData | 300.0 | OnRep_SprintSpeed | Min: 0.0 | None | Sprint speed modifier (additive to WalkSpeed: 600 + 300 = 900 total) |
| JumpVelocity | FGameplayAttributeData | 420.0 | OnRep_JumpVelocity | Min: 0.1 | 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:
cpp
// 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
cpp
// 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
cpp
// 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
blueprint
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: InfiniteBlueprint Helper Functions
| Function | Return | Description |
|---|---|---|
GetStaminaPercent() | float | Returns current stamina as normalized 0.0-1.0 value. Useful for UI stamina bars. |
HasEnoughStamina(float Required) | bool | Returns true if current stamina >= required amount. Useful for ability cost checks. |
Usage Example (Blueprint)
blueprint
Get Stamina Percent from Attribute Set
├── Target: Motion Attribute Set
└── Return: Float (0.0 to 1.0 for UI progress bar)Automatic 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
Note: WalkSpeed syncs to both MaxWalkSpeed and MaxWalkSpeedCrouched. The crouched speed is updated proportionally to maintain its ratio with walk speed (e.g., if crouched was 50% of walk speed, it remains 50% after changes).
JumpVelocity → JumpZVelocity
- Changes to JumpVelocity attribute update CMC JumpZVelocity
- Instant synchronization
- Respects network authority
The sync includes prediction handling - when the server update arrives, the client compares it against its predicted value. If values match (within 1.0 tolerance), confirmation is logged; if mismatched, a correction is logged. In both cases, the server value is applied to ensure authoritative state.
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/Crouch) 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, server correction is logged and applied (prediction cleared)