Skip to content
Plugin 1.0 · Unreal Engine 5.8Source snapshot · Version details

First inventory ​

This walkthrough creates a small authoritative inventory. Asset names below are examples you create in your project.

1. Create an item definition ​

Create an asset of type URicItemDefinition, for example ID_Ammo. Add these entries to its Fragments array:

  • Text (Name, Description): set a readable name and description.
  • Shape: Jigsaw (URicItemFragmentJigsawItemShape): set a 1 × 1 shape.
  • Stats (URicItemFragmentSetStats): set Ric.Item.Stat.MaxStackSize to 20.

You may also add Icon 2D with an icon texture. The icon is presentation data; it does not create a widget.

2. Create a container definition ​

Create URicContainerDefinition, for example CD_Main. Set its Container Fragment to Jigsaw Container Fragment:

  • Set Container Tag to Ric.Container.Type.Main.
  • Set Shape to 6 columns and 4 rows.
  • Make the intended cells open in the shape editor.

Use the main ContainerFragment property for the container implementation, not an entry in the additional Fragments array.

3. Add an inventory manager ​

Add URicContainerManagerComponent to the actor that owns the inventory. For multiplayer, the actor must replicate. Give the manager a stable, unique ID if you plan to restore it from saves.

4. Create and populate the runtime container ​

On an authority path, such as the actor's BeginPlay → Switch Has Authority → Authority:

  1. Call Add Container From Definition on the manager with CD_Main.
  2. Check that the returned container is valid.
  3. Call Add Item Definition on that container with ID_Ammo and a stack count of 12.
  4. Inspect Out Items Added. A request can be only partially fulfilled.

The C++ equivalent below is a helper you call from your authoritative setup code, after the actor and manager exist:

cpp
#include "Components/RicContainerManagerComponent.h"
#include "Definitions/RicContainerDefinition.h"
#include "Definitions/RicItemDefinition.h"
#include "Instances/RicContainerBase.h"
#include "GameFramework/Actor.h"

int32 SeedInventory(URicContainerManagerComponent* Manager,
                   URicContainerDefinition* ContainerDefinition,
                   URicItemDefinition* ItemDefinition)
{
    if (!Manager || !Manager->GetOwner() ||
        !Manager->GetOwner()->HasAuthority() ||
        !ContainerDefinition || !ItemDefinition)
    {
        return 0;
    }

    URicContainerBase* Container =
        Manager->AddContainerFromDefinition(ContainerDefinition);
    if (!Container)
    {
        return 0;
    }

    int32 Added = 0;
    Container->AddItemDefinition(ItemDefinition, 12, Added);
    return Added;
}

5. Inspect the inventory ​

Read Manager.GetContainers(), then Container.GetItems(). Each item exposes GetID(), GetDefinition(), and GetNum(). Use OnContainersChanged and OnSlotsChanged to refresh your presentation.

6. Add player-facing operations ​

For a predicted multiplayer UI, add URicItemOperationsRPCsComponent and URicClientPredictedInventoryComponent to the same owning actor as the manager. The actor must have the appropriate owning connection for server RPCs.

Render client inventory copies and submit operations through the predicted component. See Networking and prediction; do not treat local UI edits as authoritative inventory changes.

Expected result ​

The manager owns one 6 × 4 grid containing 12 items in one stack, assuming the definition's cells and filters allow placement. If nothing appears, check the troubleshooting checklist.