How-To: Add Slots with a Game Feature

Goal: give a pawn class its equipment components and slot layout from a Game Feature, so nothing is hard-wired into the pawn and a Blueprint-only project never touches a graph. (Optional - Quick Start adds the components directly.)

Prerequisites
Quick Start steps 1 and 2 (plugin enabled, slot tags authored), and a Game Feature plugin in your project.

1. Add the action to your Game Feature

Open your Game Feature Data asset, find the Actions array, press +, and choose Add Equipment Slots. The action has one editable property, Slots List - an array of requests, each matching one actor class.

Verify
The action appears in the Actions array and expands to show an empty Slots List.

2. Fill in a request

PropertyDefaultWhat it does
Actor ClassemptyThe actor class to extend. Every actor of this class (and its children) gets the components. An entry with no class is skipped.
Slot LayoutemptyThe layout applied to the slots component, exactly as you would author it on the component.
b Server ComponenttrueAdd on the server.
b Client ComponentfalseAdd on clients as well. Turn this on when client code reads the layout - to draw one UI cell per slot, for example.
b Add Equipment ManagerfalseAlso add a manager component, server only, when the actor has none. This is the Blueprint-friendly way to get the manager onto a pawn.
Slots Component ClassemptyYour slots component subclass. Empty uses UCrimsonEquipmentSlotsComponent.
Equipment Manager ClassemptyYour manager subclass - the one carrying your gating overrides. Empty uses UCrimsonEquipmentManagerComponent.
This is the no-edit route to the manager component
Ticking b Add Equipment Manager here adds the manager on the server and lets it replicate down, against any actor class you name - so a pawn gains equipment without its Blueprint being opened at all. Quick Start adds the same component by hand in the Components panel; this is the route for pawns you do not own or do not want to edit.

Set Actor Class to your character Blueprint, fill Slot Layout with the same tag/count entries you would put on the component, and tick b Add Equipment Manager. Leave b Client Component off unless your client code reads the layout.

If you made a manager subclass for gating, name it in Equipment Manager Class so the action adds yours rather than the base.

Verify
Activate the Game Feature and play: eject and select the pawn. Both components are present on the server, and the slots component shows the layout you authored.

3. Wait for it before you use it

The action runs while the Game Feature activates, so there is a window in which the pawn exists and its equipment components do not. When the layout is applied, the action announces the ModularGameplay feature state Crimson.SystemReady.Equipment (CrimsonEquipment::SystemReadyFeatureName) on that actor, server side.

There is no Blueprint node for ModularGameplay feature states. In Blueprint, bind the manager's On Equipment Changed Message event (it fires as the slots fill), or check Get Equipment Slot Layout on a short timer after possession. In C++, wait on the feature state (right).

Never bind from BeginPlay or a possession callback
Looking the components up from BeginPlay, a PlayerState-set callback, or a possession event races the Game Feature and silently finds nothing - the classic version of this bug binds to a component that does not exist yet and simply never fires. Wait on the readiness tag instead.
Verify
Put a print on the readiness callback: it fires once per pawn, on the server and on each client, and the slots component is valid inside it.

4. Know what deactivation does

Deactivating the Game Feature removes what the action added: it unregisters and destroys the slots component and, if it added one, the manager. It searches by the base classes, so a component of your subclass is still found and removed.

Removing the manager destroys the equipment
The manager's teardown force-unequips everything on the server, revoking grants and destroying spawned actors. That is correct for a feature being switched off, but it means a Game Feature that toggles mid-session wipes the player's gear. Persist it first if that matters - see How-To: Save and Restore Equipment.
It will not add a second one
The action returns early if the actor already has a slots component, and only adds a manager when the actor has none, so an actor that also creates them in C++ is left alone.
Verify
Deactivate the feature and check the pawn: both components are gone, and any equipped gear has been unequipped and its actors destroyed.

See also

  • How-To: Shape the Slot Layout
  • How-To: Gate Equipping and Unequipping
  • API Reference