Skip to content

Creating an Item

Tanvirk2013 edited this page Jun 1, 2020 · 2 revisions

Anything that must be placed in to the scene must derive from the ItemMB class. The ItemMB class uses the IInteractable interface therefore, at the bare minimum all derived objects can be interacted with. You can override functions if needed and if you would like to call the base function from the an overriden function you can use the base keyword i.e base.Awake()

All items must be hardcoded an id, name and description in the ItemDatabase class

Use the IStoreable interface if you want the player to be able to pick up an item. Likewise, use the IDroppable interface if you want the player to be able to drop an item stored in the inventory. Both interfaces support toggling of enabling storing and dropping an item respectively.

Components needed

  • An image component is needed for an IStoreable item.
  • An IDGenerator component for saving and loading. (For this to work, do not keep items at the same position)
  • A collider for interaction

Make the gameobject a prefab so that it does not lose it's references upon changing scenes

Clone this wiki locally