ModularGameplayActors
Last updated
Last updated
Modular Gameplay
Plugin OverviewA Modular Gameplay
Plugin is a plugin whose base classes implement the Modular Gameplay
pattern, which allows your project to inject components into actors at runtime.
This pattern gives the game support for .
The ModularGameplayActors
Plugin is a specific implementation of Modular Gameplay
, distributed in GCC.
You can either actually base your classes on the ModularGameplayActors
classes, or you can implement the same patterns in your own existing base classes.
UGameFrameworkComponentManager
« UGameInstanceSubsystem
This Game Instance Subsystem is what allows GCC to inject components into Actors at runtime.
Actors must explicitly opt-in to this behavior. Epic publishes the ModularGameplayActors
plugin with LyraStarterGame
and ValleyOfTheAncient
demo as an easy set of base classes to automate this opt-in process, but you don’t necessarily have to base your classes on those. You can duplicate the procedure in your own classes if you prefer.
Execute Log LogModularGameplay Verbose
in the console to see verbose logging for this module.
Execute ModularGameplay.DumpGameFrameworkComponentManagers
in the console to dump debugging info to help understand which components are being injected into which actors.
IGameFrameworkInitStateInterface
must be implemented by any Component that needs to initialize based on dependencies that themselves are other Components with their own dependent initialization steps.
TLDR every component in the Game Framework spams Init()
until everything has successfully initialized or has finally failed initialization.
To implement the Modular Gameplay
Plugin, take a look at GCCPawnExtensionComponent as an example.
Defines the UGCCPawnExtensionComponent
that drives IGameFrameworkInitStateInterface
Adds this component to every Character in the game (via base class AGCCModularCharacter
)
Implements IGameFrameworkInitStateInterface
in other components as needed
Giving this component to an Actor allows the other components on that actor to share Init State updates with each other to satisfy runtime dependencies. The components can hook into Actor Init State Changed
events broadcast by this component if/when they have runtime dependencies to satisfy.
Note that, though this is a component, there are some deep integrations in AGCCModularCharacter
for things like, for example, calling UGCCPawnExtensionComponent
🡒HandleControllerChanged
from AGCCModularCharacter
🡒PossessedBy
. If you want a deep understanding of what this component is doing, make sure you read through AGCCModularCharacter
as well.
OnRegister
Register self with ModularGameplay
plugin’s UGameFrameworkComponentManager
Pawn Extension Component implements feature name PawnExtension
BeginPlay
Bind Actor Init State Changed
event to UGCCPawnExtensionComponent
🡒OnActorInitStateChanged
Pawn Extension Component 🡒 OnActorInitStateChanged
Every time a feature (NOT including the PawnExtension
feature itself) changes state:
If new state == DataAvailable
:
Run CheckDefaultInitialization()
on all feature components
Pawn Extension Component :: CheckDefaultInitialization
This gets spammed A LOT during initialization. This is a trigger that keeps getting executed until all components have initialized successfully or finally fail to initialize.
Make sure to setup your default game instance to GCCGameInstance
in Edit->ProjectSettings->Maps And Modes -> Game Instance-> Game Instance Class
Minimal class that supports extension by game feature plugins
This class is intended to be used by Player-Controlled actors with AbilitySystemComponent living in the PlayerState
Type: EGameplayEffectReplicationMode
Enabled: Mixed
How gameplay effects will be replicated to clients
Minimal
Only replicate minimal gameplay effect info. Note: this does not work for Owned AbilitySystemComponents (Use Mixed instead).
Mixed
Only replicate minimal gameplay effect info to simulated proxies but full info to owners and autonomous proxies
Full
Replicate full gameplay info to all
Minimal class that supports extension by game feature plugins
This class is intended to be used by AI-Controlled actors with AbilitySystemComponent living in this class
Type: EGameplayEffectReplicationMode
Enabled: Minimal
How gameplay effects will be replicated to clients
Minimal
Only replicate minimal gameplay effect info. Note: this does not work for Owned AbilitySystemComponents (Use Mixed instead).
Mixed
Only replicate minimal gameplay effect info to simulated proxies but full info to owners and autonomous proxies
Full
Replicate full gameplay info to all
Minimal class that supports extension by game feature plugins
Minimal class that supports extension by game feature plugins
This class is intended to use with UGCCModularPawn
class to build AI-Controlled characters
Actor class that implement lazy loading for actor type like World Actor
The Ability System Component (ASC) can be a bit resource-intensive, especially when dealing with World Actors that require it, like Damageables. If our world is populated with such Actors, their memory footprint can become noticeable.
Think of it like this: buildings, trees, and damageable props on standby with a lower cost, only racking up the memory bill when they step into the gameplay spotlight.
Type: EGameplayEffectReplicationMode
Enabled: Minimal
How gameplay effects will be replicated to clients
Minimal
Only replicate minimal gameplay effect info. Note: this does not work for Owned AbilitySystemComponents (Use Mixed instead).
Mixed
Only replicate minimal gameplay effect info to simulated proxies but full info to owners and autonomous proxies
Full
Replicate full gameplay info to all
AbilitySystemComponent class
- AbilitySystemComponent to be use by this actor
AbilitySystemComponent Creation Policy
- Defines how a the Ability System is loaded
Attribute Sets
- Attribute Set to be use by this actor
Minimal class that supports extension by game feature plugins
This class is meant to be use with UGCCModularCharacter
with ASC living in PlayerState
Type: EGameplayEffectReplicationMode
Enabled : Mixed
How gameplay effects will be replicated to clients
Minimal
Only replicate minimal gameplay effect info. Note: this does not work for Owned AbilitySystemComponents (Use Mixed instead).
Mixed
Only replicate minimal gameplay effect info to simulated proxies but full info to owners and autonomous proxies
Full
Replicate full gameplay info to all
UGCCPawnExtensionComponent
is the implementation of the ’s functionality on a Pawn.
This tells every component on the owner Actor that supports the to try to initialize.
This class is meant to be use with
Taking a cue from Epic and the insights shared by Tranek in the excellent , Fortnite adopts a smart approach. They lazily load their ASCs in their World Actors just when they’re needed, dodging the memory hit until it’s absolutely necessary. This memory optimization is a significant boost for scalability; since ASC World Actors won’t carry that footprint unless explicitly interacted with.
()