-
Notifications
You must be signed in to change notification settings - Fork 1
Extending Plugin ‒ Creating New Containers
To create a new container, follow these steps:
-
Create a new actor component that inherits from the
GameplayContainerComponent
class. If implementing a different type of container, note that inventory, hotbar, and equipment components are available for use. -
Create a new Gameplay Tag to represent the container type. Add this tag to the owned tags of the newly created container component to uniquely define its type.
-
Create a new blueprint class inheriting from
GameplayContainerDefinition
to define the container, its configuration, and its representation in the user interface. Specify the number and type of slots, the widget for the container, and any supported notifications. Assign this definition to the container component. -
Create a new Gameplay Tag to represent the slot type. Then, create a slot definition by making a blueprint that inherits from
GameplayContainerSlotDefinition
. In this definition, assign the slot type tag, UI widgets, tags for the slot, colors, brushes, sound effects, drag-and-drop operations, etc. -
Assign the slot definition to the container definition, specifying how many slots of that type to create.
-
Optionally, add items to the startup items list for the new container component. This involves assigning an item definition, quantity, and slot type. Check
bAddStartupItemsOnBeginPlay
in the container component's advanced settings if you want startup items added whenBeginPlay
is called; otherwise, manually callAddStartupItems
as needed. -
Ensure your new container is added to an actor (e.g., Character, Pawn, Player state, Player controller, Actor, etc.).
Note: For player-owned containers, register them with an ability system component using RegisterWithAbilitySystem
and provide a reference to the ability system. Unregister using UnregisterAbilitySystem
when no longer needed and requiring uninitialized state.
Note: For containers not owned by a player or owned by other players, if it meets any conditions you might have for a player to use them, you need to call RegisterUser
and then pass in their ability system component reference for a player to be able to use those containers. When done you can call UnregisterUser
to unregister the user's ability system component and prevent it from using the other container again.