Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

235
Views
Crafting System, Removing Items doesn't remove items

I'm working on an Inventory System with a Crafting System. When I first made it it was working, it crafted items if the player had enough resources in Inventory to craft it and then removed the items that were used to craft the item and add the item we just crafted. But now the part where it should delete items that were used to craft the object doesn't work.

Function where everything starts:

public bool CraftItem() {

    //if CanCraft returned false we return false from function
    if(!CanCraft()) {

        return false;

    }

    //start crafting
    ParentCraftingSlot.StartCrafting();

    //call RemoveIngredientsFromInventory to remove item from inventory
    RemoveIngredientsFromInventory();

    //return true
    return true;

}

RemoveIngredientsFromInventory function:

//remove ingredients from inventory
//because we don't want to have the ingredients after we crafted something
private void RemoveIngredientsFromInventory() {

    foreach(Ingredient ingredient in ingredients) {

        //call RemoveItems function with ingredient item and amount
        Inventory.instance.RemoveItems(ingredient.item, ingredient.amount);

    }

}

RemoveItems function:

//RemoveItems from inventory
public void RemoveItems(Item item, int amount) {

    //loop through amount of items
    for(int i = 0; i < amount; i++) {

        //remove item from Inventory
        RemoveItem(item);

    }

}

and then RemoveItem function (i have it as a different function because I need to remove the item from the list and then invoke the changes so it's displayed and then I don't have to write it every time I just have to call the function):

//Remove Item function
public void RemoveItem(Item item) {

    //remove item from IntentoryItemList list
    InventoryItemList.Remove(item);
    onItemChange.Invoke();

}

I tried to write something into console inside the RemoveItem function and it wrote it into console but for some reason, it didn't remove the ingredients.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!