Items are in-game objects that can be added to a Bag, and represent the name and description, properties, visual representation, and other information that allows to craft, trade, use and equip them.
Creating an Item¶
Items are scriptable objects and to create one, you'll need to right click on the Project Panel and navigate to Create → Game Creator → Inventory → Item.
An Item asset will appear, with a list of sections that can be expanded or collapsed so it is easy for the user to modify and organize your items.
The ID value is a unique text that represents an item. When creating a new asset, it will be completely unique. However, duplicating an existing item will also duplicate the ID and a red message will appear above stating that there are two items with the same ID.
To solve that, expand the field and click on the Regenerate button to create a new unique ID. You can also type in a name if you follow a naming convention that ensures that all item IDs are unique.
The Prefab field is used to drop/instantiate an item onto the scene. If no prefab is provided, the item will not be instantiated.
Item A equals Item B?
Comparing two items takes into account their parent-child relationship. For example, if Item A inherits from Item B and a Condition is trying to determine if an object is equal to another one:
- A will always return success when comparing if A equals B or equals A.
- B will always return success when comparing if B equals B but not to A, because A is further down in the inheritance chain.
An Item will always return success if asked whether it is equal to itself or any of its parent items.
This section allows to define the Name. Description, Sprite representation and Color of the Item.
All these fields use dynamic properties so their values can be localized.
The shape of an Item determines the Width and Height the item occupies in the inventory bag, if it's a grid-based inventory.
It also determines the Weight of the item, in case the bag has a max weight limit.
The Max Stack field determines how many of the exact same item can be stacked one on top of another.
If an Item has one or more Sockets, the Max Stack will be automatically restricted to 1, due to technical constraints.
An Item's trading value is determined by a Currency asset and a numeric value. This value is the total pure one, without any discounts or modifiers applied.
Note that an item can only be traded using a single currency.
The price of an Item that can have other Items attached is the result of the sum of the price of all Items attached, plus the price of the Item itself.
For example, if the item Sword has a price of 45 gold and a Magic Rune costs 20 gold pieces, the value of the Sword with the rune attached will be 65 (45 + 20).
Properties define mutable values that an item defines. A Property is a data block that is identified by a name and contains a value and a text that can be used to display information about this item and use it in-game.
Use case of Properties
The most common use-case of a property is definining the attack power of a weapon. One could easily use an item that represents a Sword and add a property called
attack and has a value of 35.
See more information about this in the Properties page.
Sockets allow to attach items onto other items. The type of item that can be attached is determined using item inheritance.
For example, a socket accepts the item Rune, then all items that inherit from the Rune item will be accepted.
See more information about this in the Sockets page.
Some items can be equipped by the wearer (usually the Character with the Bag component).
See more information about this in the Equipping page.
This section allows to define the behavior of an utility Item which can be used at any given time.
A usable item can have a finite or infinite amount of usages. The Consume on Use toggle defines whether an item is consumed upon use or not.
Finite vs Infinite usages
For example, a Health Potion is consumed when used. However a Whistle can be used many times.
The Can Use conditions are executed every time a runtime item is attempted to be used. If the result is successful, the item is used.
When an Item is used, the On Use instructions are executed, where Self refers to the game object with the Bag component the item belongs to, and the Target is the references the wearer of the Bag.
Execute From Parent
Both the Can Use conditions and the On Use instructions can optionally execute the parent Item's Can Use and On Use instructions before executing itself.
This is very useful to avoid repeating the same logic over multiple items. For example, if drinking any potion results in the character executing a particular animation and playing a sound effect, these instructions can be placed in a parent Item called Potions so each child Item (Health Potion, Mana Potion, ...) does not have to.
The Crafting section allows to define recipes to create new Items as well as dismantle them into multiple ingredients.
See more information about this in the Crafting page.