58 lines
1.6 KiB
Markdown
58 lines
1.6 KiB
Markdown
---
|
||
title: "GAS (Gameplay Ability System)"
|
||
type: concept
|
||
tags: ["unreal-engine", "gameplay", "abilities", "networking"]
|
||
sources: ["unreal-multiplayer-architect", "unreal-systems-engineer"]
|
||
last_updated: 2026-05-30
|
||
---
|
||
|
||
## Aliases
|
||
- Gameplay Ability System
|
||
- 游戏能力系统
|
||
- GAS
|
||
|
||
## 定义
|
||
GAS 是 UE5 的模块化能力框架,提供技能、属性、效果(GameplayEffect)的标准化实现,内置网络预测和复制支持。
|
||
|
||
## 核心组件
|
||
|
||
### Ability (UGameplayAbility)
|
||
- 可激活的游戏能力(技能、攻击、法术)
|
||
- 支持本地和预测激活
|
||
|
||
### AttributeSet (UAttributeSet)
|
||
- 管理角色属性(生命值、魔法值、攻击力等)
|
||
- 属性自动复制
|
||
|
||
### GameplayEffect (UGameplayEffect)
|
||
- 属性的修改效果(buff、debuff、伤害、治疗)
|
||
- 可配置持续时间、周期、堆叠
|
||
|
||
### AbilitySystemComponent (UAbilitySystemComponent)
|
||
- 能力系统的核心组件
|
||
- 管理 Ability 和 AttributeSet 的生命周期
|
||
|
||
## 网络预测
|
||
GAS 内置 `FPredictionKey` 支持:
|
||
- 客户端预测能力激活
|
||
- 服务器确认或回滚
|
||
- 支持 `PredictionKey::NewManagedNetGUID()`
|
||
|
||
## 双初始化路径
|
||
```cpp
|
||
// 服务器路径
|
||
void AMyCharacter::PossessedBy(AController* NewController) {
|
||
AbilitySystemComponent->InitAbilityActorInfo(GetPlayerState(), this);
|
||
}
|
||
|
||
// 客户端路径
|
||
void AMyCharacter::OnRep_PlayerState() {
|
||
AbilitySystemComponent->InitAbilityActorInfo(GetPlayerState(), this);
|
||
}
|
||
```
|
||
|
||
## 相关概念
|
||
- [[Actor Replication]] — GAS 属性的复制机制
|
||
- [[Network Prediction]] — GAS 内置的网络预测支持
|
||
- [[Server-Authoritative Model]] — GAS 的服务器验证原则
|