Concepts

Crafting

Inventory-based crafting system.

Crafting is built on top of the item management provided by the inventory system. The basic premise is that the player can combine items to create new ones. It's a bit like cooking or baking, so it borrows some of its terminology: To craft, you need recipes that require ingredients and result in some kind of output.

Recipes specify which items are needed. When combined, the output will be one or more new items. Since crafting isn't instant, recipes should include how much work effort it takes until it is completed, which is measure in seconds.

Crafting Component

The GGCrafting component lets players combine items according to recipes to craft new items.

Your Scene
Your Scene
CraftingComponent
(GGCrafting)
CraftingComponent...
InputInventory
(GGInventory)
InputInventory...
consume
consume
OutputInventory
(GGInventory)
OutputInventory...
produce
produce
GGCraftingRecipe
(Resource)
GGCraftingRecipe...
Describes ingredients, amount of work, and crafting output
Describes ingredients, amou...
has many
has many
GGRecipeCollection
(Resource)
GGRecipeCollection...
Resource to easily store
a set of recipes at once
Resource to easily store...
has a
has a
  • A GGCraftingRecipe describes the required ingredients, work effort, and output.
  • A GGRecipeCollection contains a list of all recipes.
  • A crafting component performs the crafting based on the recipe collection.
  • The crafting component is part of a scene that represents the "machinery" (e.g. a "crafting table") which contains at least one inventory that the crafting component will source input material from and deliver output into.
  • Server-authoritative crafting system validates inputs and ensures crafted results are consistent.
  • If the output inventory is full, crafting is paused until free space to deposit crafted items becomes available.

Automated Crafting

The crafting component can craft items automatically as long as sufficient ingredients are available. Automatic crafting scans the recipe collection top-down and crafts the first-available recipe.

Manual Crafting

Of course, the crafting component can also craft items manually by letting the player select a recipe through a user interface.

Crafting Editor

Version 2 now includes a crafting editor that allows you to manage the relationships between each GGCraftingRecipe and GGItemType.

The crafting editor exports a GGRecipeCollection resource which is then associated with the GGCrafting component. This makes it easy to manage complex relationships between items and recipes.

Crafting Tips

The crafting components allows for flexible crafting setups. Here are some suggestions.

Ore Smelter

Ore smelters are popular in games that let players mine and process ore to craft items. The Smelter in Valheim is an example of this. The mechanism can be implemented with the following:

  • Create a Smelter scene as a StaticBody2D (or StaticBody3D).
  • Add an InputInventory with a GGInventoryItemFilterStrategyItemType that only allows the ore item types to be smelted.
  • Add a GGCrafting component with the crafting recipes to turn ore into ingot.
  • Add on OutputInventory to receive the crafted ingot.
  • Add an GGInteractable2D component with a custom strategy (e.g. MyInteractable2DStrategyOreSmelter): If the output inventory contains any items, transfer them to the player character's inventory. Otherwise, Add an ore item from the player character to the input inventory.

© 2023 — 2025 GodotBuilder. All rights reserved.