My aim is to make a crafting system like games such as Rust or most MMOs, where it checks if you have the items required in your inventory then lets you craft. You click a button to craft and it takes a variable amount of time to be made.
I would like to know how I would start going about doing this? Any links to guides (I have not found any to be what i’m looking for so far.)
Also how would you suggest adding items to this system, database or some sorts? What would be the easiest way to add these in to the database?
This question is out of the scope of this Q&A system, I’m afraid. It might be a better fit for the forums. You need several elements acting in unison to achieve what you are trying to do: A item class, an inventory system, and the crafting system. All are pretty complex topics, especially the inventory, so you might want to do it piece by piece and first do a tutorial for coding an inventory system, and later going towards the crafting.
To get you started in the right direction, you might want to code a simple Item class that holds values like price, weight, rarity, name, material, and so on. The inventory could just be a component on your player object that holds a list of Item instances; your backpack, so to speak. A “World Item”, which would be an Item that is actually in your world as a visible model, needs an ItemHolder component that (ta-da!) holds an Item. This way, you don’t have to have a gameobject for every item in the world and make them invisible if they are picked up; instead, you can copy the Item from the holder to the backpack, and destroy the ItemHolder gameobject.
A good way to assign item values is by using a XML database which is loaded at start to fill a dictionary with the item names as key and the actual item as value.
As for crafting, you would need a “blueprint” class which holds all the info required to combine items: Which item types, and how many of each, are required? What kind if item will be crafted? How long will it take?
var wood : float;
var showCrafting : boolean = false;
var BuildingSpawnPosition : GameObject;
var Player : GameObject;
var BuildingToCraft : Transform;
function Update ()
//Hold down a button to show the CraftingMenu if not it will stay hiden
showCrafting = true;
showCrafting = false;
function OnGUI ()
//if the crafting menu is showing and you have 5 or more wood, then there will be a button that is showing, if you press the button then it will take away the amout of wood and instantiate a building at a spesific point in your world
if(showCrafting == true)
if(wood > 4.5)
if(GUI.Button(new rect(100, 50, 100, 50), "Craft A Building"))
wood -= 5;
Instantiate(BuildingToCraft, BuildingSpawnPosition.transform.position, Quaternion.identity);