So I'm trying to make an crafting system in Unity. The problem is, I don't really know how to finish it. I already have the inventory system, (which I made using this tutorial: https://youtu.beHOW TO MAKE AN INVENTORY WITH UNITY & C# - BEGINNER TUTORIAL - 1/DLAIYSMYy2g2).
Anyways, theThe problems I'm having are:
-I don't know how to destroy the materials used for crafting an item
-And I don't really know how to check if these materials are in the inventory (or basically the scene)
- I don't know how to destroy the materials used for crafting an item
- And I don't really know how to check if these materials are in the inventory (or basically the scene)
Here's the code:
`
private Inventory inventory;
public GameObject CraftedItem;
public GameObject[] ReqMats; //This array is for requied materials
private void Start()
{
inventory = GameObject.FindGameObjectWithTag("Player").GetComponent<Inventory>();
}
public void Craft()
{
for (int i = 0; i < inventory.slots.Length; i++)
{
if (inventory.isFull[i] == false)
{
if (check if ReqMats are in inventory here)
{
inventory.isFull[i] = true;
//Destroy ReqMats here
Instantiate(CraftedItem, inventory.slots[i].transform, false);
break;
}
}
}
}
`
I also need to say that the items and itemsButtons are prefabs, and so I put needed "materials" (which are few item buttons) in the ReqMats, so I can't just use the Destroy() method cause I don't want to delete the original prefab, just the button of it's copy.
Any help will be appreciated :D