Gameplay Ability System Overview
(另含 gameplay-ability-system-for-unreal-engine 概览页)
- A framework for building abilities and interactions that Actors can own and trigger ... designed mainly for RPGs, action-adventure games, MOBAs ... supports replication for multiplayer.
- Three considerations: Tracking an Ability's Owner (the "Owner" for a Gameplay Ability is not the same as Ownership in network replication terms); Tracking an Ability's State (activated / in-progress / completed; Lyra also tracks granted); Coordinating an Ability's Execution (montages, movement control, VFX, overlap, stats, resources, block other abilities, cooldowns, interruption, cancel others, movement mode, input mid-ability, UI).
- Components: owning Actor with an Ability System Component (ASC) maintaining: list of abilities owned and activation; set of Gameplay Tags (usually status); Gameplay Attributes (enhanced float properties allowing predictive changes, replication, temporary buffs/debuffs); modifications to attributes; active Gameplay Cues. Gameplay Abilities (Blueprint or C++, can use Gameplay Ability Tasks for async). Attribute Set attached to the ASC. Gameplay Effects (modify attributes and tags compatible with network prediction; contain Gameplay Effect Components). Gameplay Effect Calculations. Gameplay Cues associated with Effects for audio/visual.
- ASC: adding/removing abilities, tracking, activating; main representation of owning Actor; in multiplayer replicates info to clients, communicates player actions to server, verifies authorization. The ASC's parent Actor must be owned by a locally controlled player for remote activation.
- Activation: (1) explicitly via Gameplay Ability Handle provided when granted; (2) Gameplay Events firing all abilities with matching Ability Trigger — preferable to abstract input and decision mechanisms; (3) Gameplay Effects with matching tags — preferred for triggering off effects (e.g. Sleep debuff); (4) Input Codes added to ASC.
- In-progress until EndAbility called; OnRemove for cleanup; Cancel mid-execution. Most GameplayAbility functions have ASC counterparts.
- Abilities have tags added to owner on activation, and lists of tags that block activation or auto-cancel.
- Gameplay Ability Tasks track inactive/in-progress/finished, can fire events, track parent cancellation. Common to extend them.
- Attributes: enhanced floats; Attribute Sets consistent reusable group; accessed through reflection; default (base) and current value tracked separately; replicate like UProperties.
- Gameplay Effects: one-shot (damage) or persistent (poison, buffs); persistent can have limited lifetime and undo changes. Instant GEs modify Base value; Duration GEs affect Current value and are undone when the GE ends. Custom Effect Calculations can process owner and target.
- Gameplay Cues: Actors and UObjects running VFX/SFX; preferred method for replicating cosmetic feedback. Associated with tags; any GE matching those tags automatically applies them (e.g. Ability.Magic.Fire.Weak). Can trigger without GE (Lyra weapon firing). Gameplay Cues do not use reliable replication ... can cause desyncs ... cosmetic only; for gameplay-relevant replicated feedback rely on Ability Tasks (e.g. Play Montage Ability Task).
- Networking: ASCs do not replicate Abilities and Gameplay Effects to all clients, only Gameplay Attributes and Tags they affect (bandwidth, anti-cheat).
- Prediction: activate locally then tell server; server may reject → undo. Some GEs support rollback: most non-instant GEs, notably excludes damage and other instantaneous attribute/tag changes. This rollback is why GEs are preferred for applying all Tags, Cues, Attribute changes.
- Server-owned objects (NPCs): interact through a locally owned Actor (usually Pawn) and a replicated ability or other server function.