Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

238
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda