Devlog 1: Jazmine Chargualaf: Creating an Inventory System
This week I had the pleasure to begin working on our brand new game called Echoes of Creation. My first task was to create the backend for the inventory system. That should be simple, right? An inventory is just a container that holds some things. However, the first question was how do I give the player that inventory container? Then I had another question what kinds of things should be allowed in the inventory?
My first thought was I could add a BP_PickupBase array variable on the player that will hold object references to child actors of BP_PickupBase. However, after some research I learned that this method is an inefficient way of storing item data and it may negatively affect performance. The method is also not modular and I’d have to rewrite code to give, let’s say, a chest it’s inventory.
A more efficient way of creating a modular inventory would be to create an Actor Component with all the variables and functions an inventory in our game would need. That way any actor in the game that needs an inventory (the player, a chest, or a bookshelf, for example) would just need the Inventory Component added to it and all the variable and functions could be accessed straight from it!
Inventory Actor Component script:
The Inventory Component attached to the player:
The other issue about storing object references in the inventory array could be avoided by using Data Tables. The data table I created uses a custom “FInventoryItem” structure that defines various attributes of a game item that can be in the inventory, including the item’s name, image for UI, item type, max stack size, and a description. Now all the information of an inventory item in the "DT_InventoryItems" data table are available to retrieve from the Inventory Component's Data Table Row Handle variable! All I have to do is make sure new inventory objects are set to the corresponding data table "row name" that defines them.
So to answer my previous question: what kinds of things should be allowed in the inventory? Any item that is in the "DT_InventoryItems" data table! If I wanted to get more specific in the future - say for a treasure chest - I could create another data table specifically for treasure items!
FInventoryItem struct script:
DT_InventoryItems Data Table.
This table will be populated with all items in the game that can be stored in the inventory!
How I used the Data Table Row Handle variable InventoryItemDataTable to pass the item's name to the Inventory Component's AddItem function:
Next Steps
This upcoming week, I will be adding more inventory items to the game and start the crafting system! Maybe use the wood to make a crafting table, perhaps? There is also a working day/night cycle that I added in blueprint but need to transfer over to code. That will be a big task but the time cycle is a must for our survival game. More to come!
Be back next week,
Jazmine Chargualaf
Files
Get Echoes of Creation
Echoes of Creation
Status | In development |
Author | FrogBoots |
Genre | Survival |
Tags | Crafting, First-Person, Singleplayer |
More posts
- Devlog3- Vivianne Zsoldos-- Player UI (PauseMenu, InventoryUI)8 hours ago
- Devlog 3 Drake Curry: Breakables v2, Navmesh, Enemy AI12 hours ago
- Devlog 3: Jazmine Chargualaf: Reworking Item Colliders & Setting Up a Sound Syst...14 hours ago
- Devlog 3: Derrick Domena-Guzman: Data Oriented Building Menu, Showing Building P...19 hours ago
- Devlog 2: Jazmine Chargualaf: Weapons, Tools, and Crafting System6 days ago
- Devlog 2 ~ Drake Curry: Level v2.0 and Learning Pains6 days ago
- Devlog2- Vivianne Zsoldos -- InventoryUI (Started)6 days ago
- Devlog 2: Derrick Domena-Guzman: Improved crouching, and functional stamina bar6 days ago
- Devlog 1 Drake Curry: Level Design, Breakables, Pickups13 days ago
- Devlog1- Vivianne Zsoldos-- Player UI (Main Menu, Player Stats)13 days ago
Leave a comment
Log in with itch.io to leave a comment.