GAS
Building gameplay with Unreal Gameplay Ability System
Me - Ben Howenstein
● Gameplay programmer
● Austin area game developer since 2014
● Previous studios/projects
○ Arkane Austin - Prey, Mooncrash
○ Airship Syndicate - Darksiders: Genesis, Wayfinder
○ WolfEye Studios - Weird West, Unannounced
Contact: ben.howenstein@gmail.com
GAS vs. Custom Ability System
Considerations
● Complexity of needs
● Provides conceptual and concrete structure for major gameplay system for “free”
● Stat-driven design (ala RPG)
● What’s the inflection point?
○ Programming resources wrespect to complex system development
● Multiplayer
○ GAS provides out of the box support for replication
● Debugging
○ System introduces significant indirection which complicates debugging
■ Can be mitigated with tooling/debug support (see GAS Debugger extension)
Ability System Component
Foundation of GAS implementation
● Responsible for all work wrespect to running abilities, applying effects, triggering cues, etc.
Which actors need one?
● Perf implications for hundreds of ASCs - not a bottleneck in practice
Possible to implement attribute support without underlying ASC
● Applicable to actors that need data but don’t require support from abilities or effects (e.g. Item class)
● Avoids small ASC performance overhead (ticking)
● Appropriate for “immutable” stats (no modification at runtime)
Principal Concepts
Attributes
● Represents state of gameplay objects
○ e.g. Health, Speed, Melee Damage, Jump Height, etc.
Abilities
● Outer unit for executing gameplay logic, comprised of atomic tasks
Effects
● Mechanism for modifying attributes
Tags
● Represent state and trigger events
Cues
● VFX/SFX - aesthetic, not meant for gameplay logic
Attributes
Mechanism for exposing and manipulating object state in GAS.
Features
● Organized into sets of conceptually related values
○ e.g. Locomotion, Health, Damage, etc.
● Supports initialization via hierarchical data
● Has concept of “base” and “current” value
● Allows validation pre/post update
What to capture
● Philosophy: only include values that need exposure to GAS system
○ Example: locomotion
■ Max Speed, Acceleration, Max Jump Height, good candidates
■ Rotation Rate (defined in movement component), perhaps not
Data
● Defined in curve table assets
● Hierarchical name-based initialization
○ GroupName.SetName.AttributeName
■ Resolution on partial string matching
■ Group name resolved per class (defined on
actor’s ASC)
○ For more details see implementation and
commentary in
FAttributeSetInitter::InitAttributeSetDefaults
Workflow is a bit sticky when dealing with large data sets in
curve table editor interface - opportunity for more seamless
integration with external spreadsheet tools (don’t rely on
Attributes
Attributes
Considerations
● Must be defined natively - introduces programmer dependency
● Only supports float data type
Attributes
Tips
● In general avoid setting attribute values directly - use effects instead (especially in concert
with replication)
● Be careful with distinction between “base” and “current” value
○ Current value contains “temporary” modifications from duration-based and infinite
effects, base value modified by instant and periodic effects
● Develop workflow for attribute data management via external spreadsheet tool
● Driving player locomotion entirely with attributes is tricky and not recommended, especially
for complex logic (directional and strafe speed)
Abilities
● Comprised of tasks (work units)
● Must be granted before activation
○ Strategies for managing overlapping abilities
■ Multiple abilities with same trigger condition granted from different sources
● Pistol and sword attack abilities granted/revoked by weapon on equip
■ Use tag conditions to enforce mutual exclusivity
● Enforces rules for activation
Abilities
Multiple abilities (same trigger tags) granted from different sources (weapons)
● Pistol
● Sword
Abilities
Use tag conditions to enforce mutual exclusivity
GA_Unholster ability
● Requires weapon holstered
Abilities
Use tag conditions to enforce mutual exclusivity
GA_Shoot ability
● Blocked by weapon holstered
Abilities
Explicit activation
Abilities
Event-based activation
● Input-based
Abilities
Event-based activation
● Example: GA_Shoot
○ Tag-based trigger event defined in ability BP
Abilities
● Grouping abilities - e.g. AbilitySet type
○ Convenience for managing groups of abilities instead of granting/revoking one-by-one
● Data passing (extensible)
○ Tag that triggered ability (if applicable)
○ Instigator - who “caused” ability (i.e. character, weapon, projectile)
○ Target - who ability is activated on (i.e. character, weapon, projectile)
○ Optional objects - arbitrary UObject pointers
○ Optional data - instanced struct, useful for passing arbitrary concrete data
○ Context Handle - gameplay effect context
○ Instigator/target tags - tags present at activation time
○ Magnitude - arbitrary float value
○ Target data - struct containing information about target of ability
Effects
Mechanism for modifying gameplay attributes and tags
● Can be indefinite or duration-based
● Applied directly or in context of ability
● Not intended for gameplay (use abilities instead)
Example: modifying movement speed (sprinting)
Effects
GE_Sprint_Speed
Speed calculation:
BaseSpeed * SpeedSprintPctModifier
Effects
Tips
● Pass gameplay effect context via ability payload
● Implement non-trivial calculations in custom calculation class
○ In general don’t invoke gameplay logic during custom calculation execution
Tags
Considerations
● Extensive editor support and validation
○ No support for string literals - all tags must be defined in config file(s)
Tags
All tags stored in 2 containers on Ability System Component
○ Main container
○ Contains tags from:
■ Abilities
■ Effects
■ Loose tags
● Replicated container
○ Contains tags from:
■ Loose tags
To serialize (or not)?
● Transient tags concept
● Name-based exclusion
○ e.g. Don’t save tags that start with “Ability”
Tags
Example: exposing input to GAS
● On input event add/remove loose tags corresponding to input type
Tags
Tips
● In general, use tag query instead of tag container in blueprint properties - much more flexible
in that it allows for complex logic beyond simple tag presence
Example - Weapon Attachment System
Example - Weapon Attachment System
● Attachment object (magazine, sight, explosive rounds, etc.)
○ On attach to weapon, apply effects and tags to character and weapon (each has its own ASC)
○ SetByCaller data is bridge between projectile definition and spawned instance
○ Target ASC: character, weapon or projectile
○ Tag and underlying attribute from weapon attachment
definition
○ Gameplay effect: effect that applies set-by-caller data to
spawned projectile ASC
○ GE approach supports combining weapon attachment
effects - i.e. spawn a bullet that bounces, explodes on
impact and applies status damage to affected targets
Example - Firing Explosive Projectile
Idea
● Execute projectile fire GA
○ Spawn projectile at correct moment via anim notify gameplay event
● Apply gameplay effect(s) to projectile on spawn
○ Gameplay effect sets attributes and tags on projectile/weapon/character
■ Damage, explosion radius, etc.
● Apply gameplay effect on projectile impact
○ Apply direct damage GE to impacted target
○ Spawn explosion volume
■ Apply GE to targets in damage volume
Example - Firing Explosive Projectile
● Activate GA_Shoot ability
○ Set up target info
○ Play fire montage (based on tag lookup - depends on
attachment supplied-tags)
○ Wait for “spawn projectile” gameplay event (via anim notify)
Example - Firing Explosive Projectile
● Spawn projectile
○ Apply set-by-caller gameplay effects to spawned projectile (i.e. explosion radius)
● Handle projectile impact
○ Apply direct damage GE to target (if applicable)
■ Damage formula: raw damage, status damage, explosion min/max radius, etc.
taken from combination of projectile, weapon and character attributes
○ Spawn explosion damage volume using explosion radius attribute from projectile’s ASC
Resources
Tools
● GAS Debugger extension is indispensable!
Resources
Documentation
● Tranek - essential reading!
● Epic
Questions
?

UnrealGameplayAbilitySystemPresentation.pptx

  • 1.
    GAS Building gameplay withUnreal Gameplay Ability System
  • 2.
    Me - BenHowenstein ● Gameplay programmer ● Austin area game developer since 2014 ● Previous studios/projects ○ Arkane Austin - Prey, Mooncrash ○ Airship Syndicate - Darksiders: Genesis, Wayfinder ○ WolfEye Studios - Weird West, Unannounced Contact: ben.howenstein@gmail.com
  • 3.
    GAS vs. CustomAbility System Considerations ● Complexity of needs ● Provides conceptual and concrete structure for major gameplay system for “free” ● Stat-driven design (ala RPG) ● What’s the inflection point? ○ Programming resources wrespect to complex system development ● Multiplayer ○ GAS provides out of the box support for replication ● Debugging ○ System introduces significant indirection which complicates debugging ■ Can be mitigated with tooling/debug support (see GAS Debugger extension)
  • 4.
    Ability System Component Foundationof GAS implementation ● Responsible for all work wrespect to running abilities, applying effects, triggering cues, etc. Which actors need one? ● Perf implications for hundreds of ASCs - not a bottleneck in practice Possible to implement attribute support without underlying ASC ● Applicable to actors that need data but don’t require support from abilities or effects (e.g. Item class) ● Avoids small ASC performance overhead (ticking) ● Appropriate for “immutable” stats (no modification at runtime)
  • 5.
    Principal Concepts Attributes ● Representsstate of gameplay objects ○ e.g. Health, Speed, Melee Damage, Jump Height, etc. Abilities ● Outer unit for executing gameplay logic, comprised of atomic tasks Effects ● Mechanism for modifying attributes Tags ● Represent state and trigger events Cues ● VFX/SFX - aesthetic, not meant for gameplay logic
  • 6.
    Attributes Mechanism for exposingand manipulating object state in GAS. Features ● Organized into sets of conceptually related values ○ e.g. Locomotion, Health, Damage, etc. ● Supports initialization via hierarchical data ● Has concept of “base” and “current” value ● Allows validation pre/post update What to capture ● Philosophy: only include values that need exposure to GAS system ○ Example: locomotion ■ Max Speed, Acceleration, Max Jump Height, good candidates ■ Rotation Rate (defined in movement component), perhaps not
  • 7.
    Data ● Defined incurve table assets ● Hierarchical name-based initialization ○ GroupName.SetName.AttributeName ■ Resolution on partial string matching ■ Group name resolved per class (defined on actor’s ASC) ○ For more details see implementation and commentary in FAttributeSetInitter::InitAttributeSetDefaults Workflow is a bit sticky when dealing with large data sets in curve table editor interface - opportunity for more seamless integration with external spreadsheet tools (don’t rely on Attributes
  • 8.
    Attributes Considerations ● Must bedefined natively - introduces programmer dependency ● Only supports float data type
  • 9.
    Attributes Tips ● In generalavoid setting attribute values directly - use effects instead (especially in concert with replication) ● Be careful with distinction between “base” and “current” value ○ Current value contains “temporary” modifications from duration-based and infinite effects, base value modified by instant and periodic effects ● Develop workflow for attribute data management via external spreadsheet tool ● Driving player locomotion entirely with attributes is tricky and not recommended, especially for complex logic (directional and strafe speed)
  • 10.
    Abilities ● Comprised oftasks (work units) ● Must be granted before activation ○ Strategies for managing overlapping abilities ■ Multiple abilities with same trigger condition granted from different sources ● Pistol and sword attack abilities granted/revoked by weapon on equip ■ Use tag conditions to enforce mutual exclusivity ● Enforces rules for activation
  • 11.
    Abilities Multiple abilities (sametrigger tags) granted from different sources (weapons) ● Pistol ● Sword
  • 12.
    Abilities Use tag conditionsto enforce mutual exclusivity GA_Unholster ability ● Requires weapon holstered
  • 13.
    Abilities Use tag conditionsto enforce mutual exclusivity GA_Shoot ability ● Blocked by weapon holstered
  • 14.
  • 15.
  • 16.
    Abilities Event-based activation ● Example:GA_Shoot ○ Tag-based trigger event defined in ability BP
  • 17.
    Abilities ● Grouping abilities- e.g. AbilitySet type ○ Convenience for managing groups of abilities instead of granting/revoking one-by-one ● Data passing (extensible) ○ Tag that triggered ability (if applicable) ○ Instigator - who “caused” ability (i.e. character, weapon, projectile) ○ Target - who ability is activated on (i.e. character, weapon, projectile) ○ Optional objects - arbitrary UObject pointers ○ Optional data - instanced struct, useful for passing arbitrary concrete data ○ Context Handle - gameplay effect context ○ Instigator/target tags - tags present at activation time ○ Magnitude - arbitrary float value ○ Target data - struct containing information about target of ability
  • 18.
    Effects Mechanism for modifyinggameplay attributes and tags ● Can be indefinite or duration-based ● Applied directly or in context of ability ● Not intended for gameplay (use abilities instead) Example: modifying movement speed (sprinting)
  • 19.
  • 20.
    Effects Tips ● Pass gameplayeffect context via ability payload ● Implement non-trivial calculations in custom calculation class ○ In general don’t invoke gameplay logic during custom calculation execution
  • 21.
    Tags Considerations ● Extensive editorsupport and validation ○ No support for string literals - all tags must be defined in config file(s)
  • 22.
    Tags All tags storedin 2 containers on Ability System Component ○ Main container ○ Contains tags from: ■ Abilities ■ Effects ■ Loose tags ● Replicated container ○ Contains tags from: ■ Loose tags To serialize (or not)? ● Transient tags concept ● Name-based exclusion ○ e.g. Don’t save tags that start with “Ability”
  • 23.
    Tags Example: exposing inputto GAS ● On input event add/remove loose tags corresponding to input type
  • 24.
    Tags Tips ● In general,use tag query instead of tag container in blueprint properties - much more flexible in that it allows for complex logic beyond simple tag presence
  • 25.
    Example - WeaponAttachment System
  • 26.
    Example - WeaponAttachment System ● Attachment object (magazine, sight, explosive rounds, etc.) ○ On attach to weapon, apply effects and tags to character and weapon (each has its own ASC) ○ SetByCaller data is bridge between projectile definition and spawned instance ○ Target ASC: character, weapon or projectile ○ Tag and underlying attribute from weapon attachment definition ○ Gameplay effect: effect that applies set-by-caller data to spawned projectile ASC ○ GE approach supports combining weapon attachment effects - i.e. spawn a bullet that bounces, explodes on impact and applies status damage to affected targets
  • 27.
    Example - FiringExplosive Projectile Idea ● Execute projectile fire GA ○ Spawn projectile at correct moment via anim notify gameplay event ● Apply gameplay effect(s) to projectile on spawn ○ Gameplay effect sets attributes and tags on projectile/weapon/character ■ Damage, explosion radius, etc. ● Apply gameplay effect on projectile impact ○ Apply direct damage GE to impacted target ○ Spawn explosion volume ■ Apply GE to targets in damage volume
  • 28.
    Example - FiringExplosive Projectile ● Activate GA_Shoot ability ○ Set up target info ○ Play fire montage (based on tag lookup - depends on attachment supplied-tags) ○ Wait for “spawn projectile” gameplay event (via anim notify)
  • 29.
    Example - FiringExplosive Projectile ● Spawn projectile ○ Apply set-by-caller gameplay effects to spawned projectile (i.e. explosion radius) ● Handle projectile impact ○ Apply direct damage GE to target (if applicable) ■ Damage formula: raw damage, status damage, explosion min/max radius, etc. taken from combination of projectile, weapon and character attributes ○ Spawn explosion damage volume using explosion radius attribute from projectile’s ASC
  • 30.
    Resources Tools ● GAS Debuggerextension is indispensable!
  • 31.
    Resources Documentation ● Tranek -essential reading! ● Epic
  • 32.