This page explains how to pick, move, drop, use, equip (and more) your items, and how to have them do actual things when these actions happen.

Item Actions

Items can be stored but there are also actions you can perform on them, depending on your item’s settings. They’re all defined in the InventoryItem class, from which all scriptable object items inherit. By default, all these actions are blank, and it’s up to you to override them in your item classes.

Here are the possible actions that can be overridden to trigger stuff when they happen :

  • Pick
  • Use
  • Equip
  • UnEquip
  • Swap
  • Drop

For all these actions, you just need to implement what you want to happen in addition to the default action (adding the item to inventory on pick, equipping the item on equip, etc.).

Actions examples

The Inventory Engine comes with examples of how to override these methods. Here are a few of them.

Equip : When an armor gets picked in the PixelRogue demos, we call the Player’s SetArmor method, to reflect the equipped armor on its sprite.

public override void Equip()

Use : This one comes from the Corgi Engine. When a Health item gets picked up, we check we have an owner (this is bound automatically by the CharacterInventory ability), we then get its Health component, and call the GetHealth method with the item’s HealthBonus value as a parameter, which increases its current health.

public override void Use()

	if (TargetInventory.Owner == null)

	Health characterHealth = TargetInventory.Owner.GetComponent<Health>();
	if (characterHealth != null)

As you can see, implementing actions and effects for your items is very simple, and the possibilities are endless.