Skip to main content

Quick Start

Preface

Prerequisites

  • The plugin has been installed to the engine.

Goals

  • Add an inventory for the player.
  • Define a simple item.
  • Spawn the item and drop it into the world.
  • Move the world item into the player's inventory when the player's pawn walks near the item.

Guide

Add an Inventory Component to the Player

  1. Open up your PlayerState class and add a BLSimpleInventoryComponent.
  2. Change the Inventory Init Policy to From Inventory.
  3. Click the + button for Initial Storage to add an item slot.
  4. Ensure Auto Initialize Slots is true.

Create a World Item Class

The world item class is the actor that represents our item in the world.

Add a new blueprint whose parent is BLWorldItem. Name it BP_BallWorldItem.

note

For most games, you will want a more generic world item actor that takes its mesh from the item definition. This is included in the example map, but for simplicity we will use a hard-coded actor here.

Open BP_BallWorldItem and add a Static Mesh Component. Change its mesh to Sphere and its material to MI_Solid_Blue (This material is available by default in most UE5 starter maps).

Pick Up When Walking Nearby

When our player's pawn walks nearby the world item, we want to pick it up by moving the item into the player's inventory.

  1. Add a sphere collision component to the world item blueprint named Pickup Collider.
    1. Set its Sphere Radius to 25.
  2. Add the On Component Begin Overlap Event from the Pickup Collider.
  3. Add these nodes after the event:

World Item Pickup

  • Switch Has Authority: Ensure the deposit can only occur on the server. While Bolt includes client-side prediction, we won't go over it in this guide. See the example map for details.
  • Get World Item Slot Handle: Get the world item actor's single item slot.
  • Try Transfer (Slot to Inventory): Try to transfer the item from the world item slot to any slot in the player's inventory.
  • Log If Failure (Output Log): Log the result to the output log if the transfer fails.

Create an Item Definition

In the asset browser, create a new item definition asset by right clicking and selecting Gameplay -> Item Definition from the context menu. Name the new asset ID_Ball.

New Item Definition Asset

Open ID_Ball. This asset represents a single type of item; the definition stores all data that doesn't change at runtime:

For the quick start, we will change two things:

  1. Change the World Item Class to BP_BallWorldItem from the section above. This lets us drop this item into the world as an actor.
  2. Change the Item Icon to Sphere_64x from the engine. This icon will be used for the asset's thumbnail.

Ball Item Def

Spawn Items

You may spawn items from any actor, but for this demonstration we will use the level blueprint for simplicity.

  1. Open the level blueprint.
  2. Dragging from the BeginPlay node, add the function Try Spawn Item Stack.
    1. Select ID_Ball for the item definition.
    2. Set ItemCount to 1.
note

This node can fail if any of its parameters are invalid. In this case, the Return Value pin will contain the error that occurred and ItemStack will be null.

Spawn Item Stack

Drop Items As Actors

  1. To drop this item into the world, drag from the Item Stack pin and add the function Try Drop Items.
    1. Request Count: The number of items to drop from the stack. It defaults to As Many As Possible.
    2. Owner: The actor which will own the dropped item actor.
    3. Instigator: Instigator for the dropped item actor.
note

Like the Spawn Item Stack node, this node can fail.

Drop Item Stack

This will spawn an actor from the item definition's World Item Class:

Item In World

After moving close to the item actor, it will be picked up:

Item In Inventory

The item in the example map's inventory widget. Note that creating the widget was not included in this guide.

Continue From Here

The example map contains many features that would be difficult to completely document here. We recommend looking through it for ideas on how to implement things:

  • See the inventory widgets for examples, and how to use the inventory controller.
  • See the IS_Equipment blueprint for most of the customizations you would expect from an RPG item.
  • See the cosmetic defs for cosmetic examples.
  • If you have our randomization plugin, Stoch, see the BoltExample_Stoch map for integration examples.