$npx -y skills add quodsoler/unreal-engine-skills --skill ue-game-featuresUse this skill when working with Game Feature plugins, modular gameplay, GameFeatureAction, GameFeatureData, GameFrameworkComponentManager, init state system, experience system, modular components, UPawnComponent, UControllerComponent, UGameStateComponent, UPlayerStateComponent,
| 1 | # UE Game Features and Modular Gameplay |
| 2 | |
| 3 | You are an expert in Unreal Engine's Game Features plugin system and modular gameplay architecture. |
| 4 | |
| 5 | ## Context Check |
| 6 | |
| 7 | Read `.agents/ue-project-context.md` before proceeding. Determine: |
| 8 | - Whether the `GameFeatures` and `ModularGameplay` plugins are enabled |
| 9 | - Which actors register as component receivers (`AddReceiver`) |
| 10 | - Whether the project uses an init state system or experience-based loading |
| 11 | - Existing `UGameFeatureAction` subclasses or modular component base classes |
| 12 | |
| 13 | ## Information Gathering |
| 14 | |
| 15 | Ask the developer: |
| 16 | 1. Are you creating a new Game Feature plugin or extending an existing one? |
| 17 | 2. What components or abilities should the feature inject into gameplay actors? |
| 18 | 3. Does the feature need async loading or runtime activation/deactivation? |
| 19 | 4. Is there an experience/game mode composition system (Lyra-style)? |
| 20 | 5. Do components need ordered initialization across features? |
| 21 | |
| 22 | --- |
| 23 | |
| 24 | ## Game Feature Plugin Structure |
| 25 | |
| 26 | A Game Feature plugin is a standard UE plugin with `Type` set to `"GameFeature"` in its `.uplugin` descriptor. This tells the engine to manage its lifecycle through the Game Features subsystem rather than loading it as a regular plugin. |
| 27 | |
| 28 | ### .uplugin Descriptor |
| 29 | |
| 30 | ```cpp |
| 31 | { |
| 32 | "Type": "GameFeature", |
| 33 | "BuiltInInitialFeatureState": "Active", // or "Registered", "Installed" |
| 34 | "Plugins": [ |
| 35 | { "Name": "GameFeatures", "Enabled": true }, |
| 36 | { "Name": "ModularGameplay", "Enabled": true } |
| 37 | ] |
| 38 | } |
| 39 | ``` |
| 40 | |
| 41 | `BuiltInInitialFeatureState` controls how far the plugin advances on startup. Use `"Active"` for always-on features, `"Registered"` for features activated by gameplay code, or `"Installed"` for downloadable content loaded on demand. |
| 42 | |
| 43 | ### UGameFeatureData |
| 44 | |
| 45 | Each Game Feature plugin contains a `UGameFeatureData` primary data asset (extends `UPrimaryDataAsset`) that defines what the feature does: |
| 46 | |
| 47 | ```cpp |
| 48 | // From GameFeatureData.h |
| 49 | UPROPERTY(EditDefaultsOnly, Instanced, Category = "Game Feature | Actions") |
| 50 | TArray<TObjectPtr<UGameFeatureAction>> Actions; |
| 51 | |
| 52 | UPROPERTY(EditAnywhere, Category = "Game Feature | Asset Manager") |
| 53 | TArray<FPrimaryAssetTypeInfo> PrimaryAssetTypesToScan; |
| 54 | ``` |
| 55 | |
| 56 | `Actions` is the core — an instanced array of `UGameFeatureAction` subclasses that execute when the feature activates. |
| 57 | |
| 58 | ### Directory Convention |
| 59 | |
| 60 | ``` |
| 61 | Plugins/GameFeatures/ |
| 62 | ├── ShooterCore/ |
| 63 | │ ├── ShooterCore.uplugin (Type: GameFeature) |
| 64 | │ ├── Content/ |
| 65 | │ │ └── ShooterCore.uasset (UGameFeatureData) |
| 66 | │ └── Source/ShooterCoreRuntime/ |
| 67 | └── DeathmatchRules/ |
| 68 | ├── DeathmatchRules.uplugin |
| 69 | └── Content/DeathmatchRules.uasset |
| 70 | ``` |
| 71 | |
| 72 | --- |
| 73 | |
| 74 | ## Plugin State Machine |
| 75 | |
| 76 | Game Feature plugins transition through a well-defined state machine. Actions fire at specific transitions and runtime activation must target valid destination states. |
| 77 | |
| 78 | ### EGameFeaturePluginState Lifecycle |
| 79 | |
| 80 | ``` |
| 81 | Uninitialized → Terminal → UnknownStatus → StatusKnown |
| 82 | → Installed → Registered → Loaded → Active |
| 83 | ``` |
| 84 | |
| 85 | Each major state has transition states between them (e.g., `Registering`, `Loading`, `Activating`). You target a destination state and the subsystem walks the chain. |
| 86 | |
| 87 | ### Destination States |
| 88 | |
| 89 | | State | Description | |
| 90 | |-------|-------------| |
| 91 | | `Terminal` | Plugin removed from tracking entirely | |
| 92 | | `StatusKnown` | Availability confirmed (exists on disk or bundle) | |
| 93 | | `Installed` | Files on local storage, not yet registered | |
| 94 | | `Registered` | Assets registered with Asset Manager, actions notified | |
| 95 | | `Loaded` | Assets loaded into memory | |
| 96 | | `Active` | Actions fully activated, components injected | |
| 97 | |
| 98 | URL protocols: `file:` for built-in disk plugins, `installbundle:` for downloadable features. Convert descriptor path to URL with `UGameFeaturesSubsystem::GetPluginURL_FileProtocol(Path)`. |
| 99 | |
| 100 | --- |
| 101 | |
| 102 | ## UGameFeatureAction |
| 103 | |
| 104 | `UGameFeatureAction` (`UCLASS(MinimalAPI, DefaultToInstanced, EditInlineNew, Abstract)`) is the base class for all actions. `DefaultToInstanced` + `EditInlineNew` allow instances to be created inline within `UGameFeatureData`'s `Actions` array. |
| 105 | |
| 106 | ### Lifecycle Methods |
| 107 | |
| 108 | ```cpp |
| 109 | // Registration phase |
| 110 | virtual void OnGameFeatureRegistering(); |
| 111 | virtual void OnGameFeatureUnregistering(); |
| 112 | |
| 113 | // Loading phase |
| 114 | virtual void OnGameFeatureLoading(); |
| 115 | virtual void OnGameFeatureUnloading(); |
| 116 | |
| 117 | // Activation — primary override point |
| 118 | virtual void OnGameFeatureActivating(FGameFeatureActivatingContext& Context); |
| 119 | virtual void OnGameFeatureActivating(); // legacy no-arg fallback |
| 120 | |
| 121 | // Post-activation confirmation |
| 122 | virtual void OnGameFeatureActivated(); |
| 123 | |
| 124 | // Deactivation — supports async |