Creating a new Item
Last updated
Last updated
Creating a new item is also incredibly simple.
The items all use Scriptable Objects to hold the data for the items such as:
ID - Unique ID Number (MUST BE UNIQUE FOR THE SAVE SYSTEM TO WORK)
Name - Name of the Item
Rarity - Rarity of the Item
Not Sellable - Used typically for Quest/Key Items
Sell Value - What is the item worth in the world when selling?
Type - The type of item - See the Setting up Item/Inventory Types for more information
Sub-Type - The Sub-Type of the item.
Icon - The Icon used
Description - The Description of the Item
Subtitle Text - The Subtitle Text
In World Prefab - The Prefab used when dropping an item back into the world
Those are the basic parameters for an item. Other parameters include:
Stackable - Is the item Stackable?
Max Stacks - How many can a stack hold?
Equippable - Is the item Equippable - YES for Weapons, NO for everything else
Usable - Is the item Usable e.g. For herbs, or apples to eat etc.
Droppable - Is the item droppable into the world? If yes, make sure you have an In World Prefab set.
Discardable/Deletable - Is the item discardable e.g. Can the item simply be deleted and removed from the game?
To create a new item, do the following:
Right-Click in your folder structure where you want to create the items, then Create ->Malbers Inventory -> New Item
When you create a new item, you'll need to set up it's parameters like the screenshot at the top of the page.
Make sure everything is filled in and especially that the ID of the item is unique.
The in-world prefab is used for when picking up the item, and dropping the item. The prefab is what you interact with to pick up, and what gets instantiated and dropped when dropping from the inventory.
By default, you may not have any prefabs ready to go although some are included such as an Axe, Sword, Meat etc.
In order to set up a prefab, it's always best to refer to one of the examples so that you don't miss anything but in general, all you need on the item is a pickable component and to add an Inventory Item component.
For the pickable component, you can refer to other tutorials in how to set this up correctly, but as an example:
It's important that for items that aren't persistent in the world e.g. an apple, or a fish etc you set Collectable and Destroy Collectable as TRUE/ON.
By setting those settings to TRUE/ON this will make sure they are collectable and will destroy the in world prefab when collected.
If your item does not have an Inventory Item component, add one. Next, on the Inventory Item component, you will drag in your item scriptable object, to the Inventory Item reference, and set the quantity that you want to give. For most cases, and especially weapons, set this to 1.
Set the Gameobject Layer of your new Prefab item to "Item" and then drag it into the scriptable objects In World Prefab reference, as stated above.
The final task is to register the item with the InventoryMaster (Order does not matter!)
And that's it - you are now ready to pick up items!
Note - if you are setting up Weapons - ensure you set up those items according to the Weapons tutorial on Youtube here to be able to Equip/Unequip as well as the steps above: https://www.youtube.com/watch?v=6iBFcfE7QI0