Skip to content

Recipe: Put a Pickup into Inventory

Outcome: interacting with a world object adds one item and hides the pickup for a timed respawn.

Execution model

  • Authority — State Authority creates and inserts the item and starts the respawn timer.
  • Prediction — inventory mutation is not predicted; the client may show a pending interaction only.
  • Replicated — pickup availability, respawn deadline, item definition, seed, quantity, and placement.
  • Local only — prompt, pickup glow, sound, toast, and drag/slot animation.

1. Create the item

Create an ItemDefinition, assign its catalog ID, and apply an ItemScheme. For the first test, use a one-cell item with no generated affixes. Confirm the definition passes schema normalization.

2. Configure the character

Add CharacterInventory and assign a small SlotInventoryLayout. Grant InteractAbility and confirm the input prompt already works with a simple interactable.

3. Create the pickup

Duplicate ShowcaseInventoryPickup, assign your definition, and register its actor prefab with Fusion. The authoritative interaction creates an ItemInstance and inserts it through the layout:

csharp
if (ItemInstance.TryCreate(itemDefinition, default, 1, out var item) &&
    character.Inventory.Layout.Add(item))
{
    WasPickedUp = true;
    RespawnTimer = TickTimer.CreateFromSeconds(Runner, respawnDelay);
}

Verify

Pick the item up with peer one. Both peers should see the pickup disappear, but only the interacting character's inventory should contain it. Wait for the replicated respawn timer and collect it again.

Understand the system

Continue with Manual: Inventory for fragments, schemas, stacks, slot layouts, and tetris placement.

RedEngine Framework documentation