Containers

Storage containers provide your player with additional storage options when the inventory and bank just isn’t enough. Storage containers can be placed anywhere in the world, and can be used to store and retrieve items by any player.

The only limitation with storage is for multiplayer only, and that is it will only let one person access the storage container at a time. This is to prevent a possible latency driven dupe. The system will alert you if you try to open a container that is already being viewed by another player.

Other than this, storage containers function the same as any other storage component.

How Containers Work

Containers are interactable actors that have a storage component on them. When you interact with a storage container you are assigned as the owner, and shown the contents of the container through the UI_TargetStorage widget in the UIs/Storage/ folder.

Our base class for containers is the BP_Interactable_Container actor found in the Blueprints/Interactables/ folder. This inherits from our BP_Interactable class for its interactable functionalities, and our workstations are an extension of the container (the workstation actor inherits from the container actor class).

The save system associates the items to the specific container between play sessions using a UniqueIdentifier string variable. This variable is on the actor, and it is your responsibility for setting a unique one to it for each instance of your actor. I have included a simple way to auto generate unique identifiers, but it requires all actors to exist in the world at the time of start.

Since our workstations are an extension of our container blueprint the same principle of uniquely identifying them is also required.

This method is intended to help you test the functionality and get started until you come up with a way to generate your own unique identifiers for the actors. Typically this is done from some sort of manager keeping track of them all. Once you have a solution you can simply input your unique identifier into this string.

Create a New Container

As mentioned above containers are an interactable, to create a new one you will do the following:

  1. Navigate to the Blueprints/Interactables/ folder.
  2. Drag a copy of the BP_Interactable_Container blueprint into your level.
  3. Select the instance, and then the mesh component, then select your mesh for your container. You can find the ones included with the asset in the Demo/Containers/Boxes/ folder.
    You can also make a child of this BP_Interactable_Container blueprint and set the mesh inside of the blueprint for easier reusability. Then you can just drag and drop a copy of this new blueprint in without having to set the mesh every time.
  4. From the details panel enter a UniqueIdentifier, or if all of your actors will be loaded into the level on begin play you can set the autoGenUniqueIdentifier boolean to true to generate your unique identifiers, and if you are manually entering your identifiers make sure this boolean is set to false.

Container Configuration

To configure a container select the AC_Inventory_Storage component on it. From here you can define the SlotCount, BuyableSlots, as well as any StarterItems.

Customize the Container Window

We refer to our container's window as the target storage window. This is the UI that is shown when you interact with a remote storage. This includes containers, bankers, and loot crates. This is the window that shows the items found in the actor’s storage component. It is also how the player adds and removes items from it.

The UI_TargetStorage widget can be found in the UIs/Storage/ folder.

Keep in mind that this window is used for storage containers, loot containers and the player banking system.

We can customize the Window Title Text, Icon, Open and Close Sounds used by the containers by customizing the WindowTitle, WindowIcon, WindowOpenSound and , WindowCloseSound found in the Container blueprint. If you don’t see them in the My Blueprint panel you will need to enable inherited variables (click the gear icon then enable Show Inherited Variables).

View the Sounds chapter to learn how to customize the other sounds.