Video summary
Data models - using data to create extensible, maintainable games in Godot
Main summary
Key takeaways
Main idea: replace node-heavy item logic with data models (Godot Resources)
- The tutorial explains that building all item/game logic directly with Godot Nodes/Scenes becomes hard to extend and maintain as features grow (e.g., the same weapon must exist both in-world and in inventory/in-dialogs).
- It introduces data models as “plain objects” that store item data independent of how it’s rendered/used.
- Focus: using Godot Resource types to represent:
- Items (name, 3D representation, UI icon, later price)
- Inventory contents
- Crafting Recipes (ingredients and results)
- Goal: make systems reusable and extensible—UI, world pickup, inventory, and crafting all consume the same data.
Tutorial 1: World pickup using data models
Problem implemented
- Player (“Mr. G”) moves around and collects items from the ground.
Key technical approach
- Use an Area3D with collision shape and
body_enteredsignal to detect pickup. - Define a contract: the player implements
on_item_picked_up(...), and the pickup calls it when the player enters the area. - Initially, the tutorial demonstrates an items database as a
Dictionaryscript:items.gdstores entries keyed by an item ID- Each item entry initially contains
nameand later ascenepath for world representation
- The pickup node exposes an exported
item_idand then:- looks up the item in the database
- gives the player the ID so the player can resolve item data
- instantiates the item’s 3D scene under the pickup automatically
Drawbacks called out
- Typos are easy:
- wrong
item_idstrings - wrong keys in the database dictionary
- wrong
- Using scene paths as strings can silently break when scenes move/rename.
- Large dictionaries (hundreds of items) become difficult to maintain.
Tutorial 2 (better): Use Godot custom Resource for Items
Item resource
- Create
item.gdextending GodotResource. - Use exported fields editable in the inspector:
name(String)scene(PackedScene) for the 3D representation- later
icon(Texture2D) andprice(int)
- Advantages emphasized:
PackedScenefixes references more robustly than hard-coded strings/paths.- Godot maintains references when reorganizing/renaming assets.
- Avoids item-ID string typing errors.
How pickup changes
- Pickup now exports a direct reference to an
item: Itemresource. - The pickup instantiates
item.sceneinready(). - Instead of calling
on_item_picked_up(id), it callson_item_picked_up(item).
Player/inventory simplification
- Player no longer needs an items database lookup:
- it directly uses fields from the received
itemresource (e.g.,item.name).
- it directly uses fields from the received
Reusable component
- The pickup is saved as a separate scene (e.g.,
pickup.tscn) so it can be duplicated and configured per item (pickaxe, sword, etc.).
Tutorial 3: Inventory as a data model + inventory dialogue UI
Inventory model
inventory.gdextendsRefCounted.- Stores:
content: Array[item]
- Methods:
add_item(item)remove_item(item)(removes first occurrence)get_items()
Inventory integration
- Player owns an
inventoryinstance. - Pickup calls
player.inventory.add_item(item).
Inventory UI
- Builds
inventory_dialog.tscn(PanelContainer with title + close button). - Uses an
item_slot.tscnscene to show an item icon. inventory_dialog.gd:open(inventory)populates a grid with one slot per inventory item- connects close button to hide the dialogue
- uses scene-unique node names so script references don’t break when UI hierarchy changes
- Input handling:
- Added CanvasLayer and a
UI root.gdscript. - Pressing an input action (key I) opens the inventory dialogue.
- Fix for 3D mouse capture: dialogue shows mouse (
input.mouse_mode_visible) and restores captured mode when closing.
- Added CanvasLayer and a
- Bugfix covered:
- Opening the dialogue multiple times initially duplicates slots; fixed by clearing grid children before repopulating.
Tutorial 4: Crafting system using Resource-based data models
Crafting data
recipe.gdextendsResourcewith exported fields:nameingredients: Array[item]results: Array[item]
- Multiple recipe resources are created in a
recipesfolder:- Example: iron ingot recipe, pickaxe recipe, etc.
Crafting dialogue
crafting_dialog.tscnis derived from inventory UI layout:- left side: recipe list (
ItemList) - right side: ingredient grid + result grid
- craft button
- left side: recipe list (
- The tutorial adds a reusable UI component:
item_gridscene that can display arrays of items (usingitem_sloticons).
- Wiring selection to recipe data:
- When populating the
ItemList, it uses metadata:set_item_metadata(index, recipe)
- On selection change, retrieves the recipe with
get_item_metadata(...).
- When populating the
Crafting behavior
- Craft button handler:
- removes each ingredient item from the inventory
- adds each result item to the inventory
- Two key fixes implemented:
- Auto-select first recipe on open:
- calls list
select(0)and manually triggers the selection update because selection-by-code doesn’t emit the same signal.
- calls list
- Disable craft unless inventory contains all ingredients:
- adds
inventory.has_all(items_array):- duplicates the required array
- iterates inventory content and erases matches from the “needed” list
- returns true if nothing remains
- adds
- Auto-select first recipe on open:
Recursive crafting dependency tested
- Example flow tested:
- Add iron ore → craft iron ingots → craft pickaxe
- Craft button correctly disables/enables based on ingredient availability.
Export/runtime loading fix: dynamically load recipes reliably
Issue
- In-editor loading works, but exported builds fail to load recipe
.tresfiles. - Reason explained:
- Godot export packs resources into
.pckand may rename/replace.tresinto.remapentries. - A filesystem-based approach (listing DirAccess) breaks at runtime because paths/filenames don’t match the expected
.treslayout.
- Godot export packs resources into
Initial workaround discussed
- “Hacky” approach: detect
.remap—rejected as fragile.
Robust solution via plugin
- Uses a plugin: Godot Resource Groups
- Creates a
ResourceGroupresource (e.g.,all_recipes.tres) - Configured to include
recipes/*.tres - The plugin maintains an up-to-date list of resource paths (handles adds/removes/renames)
- Creates a
- The crafting dialogue’s script exports this resource group and calls
load_all_into(...). - Verified by exporting and testing: all recipes appear in exported game.
Data maintenance / balancing workflow: editing many item fields
Problem addressed
- When adding fields like
price, default values cover new fields, but custom tuning becomes tedious at scale (hundreds of items). - Also lack of spreadsheet-like overview makes balancing hard.
Solution via plugin
- Uses plugin: Edit Resources as Table 2
- Adds a “resource tables” tab in Godot
- Automatically collects items/resources from a folder (e.g.,
data/items) - Provides table view with sorting/filtering
- Supports bulk editing and filtering via GDScript expressions (example shown:
res.price is less than seven)
- Purpose: easier balancing by editing game data directly in-editor with spreadsheet-like tooling.
Key takeaways / “what you learn”
- Represent items/recipes as Godot Resources rather than node graphs or string-based dictionaries.
- Use exported
PackedScene,Texture2D, and direct resource references to avoid typos and broken paths. - Build reusable UI components that consume the same data models:
- inventory dialogue, crafting dialogue, item slots/grids
- Use proper separation of concerns:
- pickups interact with item resources
- player stores inventory data model
- UI displays data model without embedding gameplay logic
- For scalable data loading in exported builds:
- don’t rely on directory scanning for
.tres - use a resource grouping plugin (Resource Groups)
- don’t rely on directory scanning for
- For maintainability of large datasets:
- use resource table editor plugin to balance/tweak values like prices.
Main speakers / sources
- Source: Single tutorial video narrator (no distinct named speakers provided in subtitles).
- Product/engine source referenced: Godot Engine (official features like Nodes/Scenes, Resources, signals, PackedScene, export workflow).