# Inventory System with Save Game

**URL:** <https://forums.unrealengine.com/t/inventory-system-with-save-game/273721>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [January 20, 2022, 12:04pm UTC](https://forums.unrealengine.com/t/inventory-system-with-save-game/273721 "2022-01-20T12:04:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aumenn2003](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/aumenn2003/32/88718_2.png) [@Aumenn2003](https://forums.unrealengine.com/u/Aumenn2003)\
**Post date:** [January 20, 2022, 12:04pm UTC](https://forums.unrealengine.com/t/inventory-system-with-save-game/273721/1 "2022-01-20T12:04:41Z")

</div>

Hi people. So I’m working on this game where I wanna give the player the choice to choose from a variety of skins for both the knife and the cake. I’ve never worked with save games or inventory systems before, that is why I wanna share with you my approach so you can advise me.  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/4/c/4cb0bb44d49f9c67490472e69863a93455bc92d9.png)

Here is what I’m thinking to do. I’d store all my knife (I’ll use just the knives for example) button images in an array within the main menu widget and create an integer variable within the save game that would would check which knife is selected when the GameInstance is initiated and assigns the correspondent item from the image array.

This sounds confusing but I hope you get what I’m trying to say.  
Thanks!

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 20, 2022, 12:28pm UTC](https://forums.unrealengine.com/t/inventory-system-with-save-game/273721/2 "2022-01-20T12:28:40Z")

</div>

> [@Aumenn2003](#):
>
> and create an integer variable within the save game

I might be missing the point, but wouldn’t it be more convenient to save the (soft) asset reference rather than its ID, and then be forced to fetch it from the array.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/d/0/d05c1f51259b72265c0c1909f6cbd60750fbc34d.png)

The above picture (psedoscript) demonstrates the retrieval after loading the save game (soft assets need loading, though). This way you wouldn’t need to worry about keeping track of IDs, which _can_ be a royal pain in the neck at times.

* * *

In short, save the asset itself, not its ID.

---

<div class="post-metadata">

**Author:** ![Aumenn2003](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/aumenn2003/32/88718_2.png) [@Aumenn2003](https://forums.unrealengine.com/u/Aumenn2003)\
**Post date:** [January 20, 2022, 12:40pm UTC](https://forums.unrealengine.com/t/inventory-system-with-save-game/273721/3 "2022-01-20T12:40:40Z")

</div>

Thanks for the new perspective. I don’t know if it’s optimal but I thought I’d choose an integer variable because it would keep track of both the image to display and the knife child BP that’s supposed to spawn in the level.  
If I understand, following your method, I’d need 2 variables, one for the image and one for the knife BP. How can connect between them?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 20, 2022, 1:37pm UTC](https://forums.unrealengine.com/t/inventory-system-with-save-game/273721/4 "2022-01-20T13:37:16Z")

</div>

> How can connect between them?

Somewhat hard to advise something tangible without knowing the scope / structure but do consider the following:

- normally, one does not save variables 1 by 1; even for a small, simple game that’d be really awkward.

- here’s a struct (just a bunch of data) that represents an in-game item the player can carry:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/8/b/8b0fb2ee68bd6479133bf37408e58056aacb2bbd.png)

Any default values should be in the class itself, variables that can change, should form the rest of the struct above. `Default skin` does not really belong here for example, it can be tucked away in the class.

- over the course of the game, the player will acquire new items and, eventually, we’ll need to save them (you can’t save a spawned actor, so you save the data that defines it):

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/e/3/e324891230e2f3387ed36f7b599f23fd635d9a1f.png)

- when you load the game, you respawn the actors and feed them their data from the save game:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/0/4/04c0a4ae683b87e00b4bc75a52f015603d0ceb32.png)

* * *

The above is more of a top-down view hoping to answer this:

> I’d need 2 variables, one for the image and one for the knife BP. How can connect between them?

[Structs](https://couchlearn.com/how-to-use-structs-in-unreal-engine-4/) can associate data, it’s a container.

---

<div class="post-metadata">

**Author:** ![Aumenn2003](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/aumenn2003/32/88718_2.png) [@Aumenn2003](https://forums.unrealengine.com/u/Aumenn2003)\
**Post date:** [January 20, 2022, 1:40pm UTC](https://forums.unrealengine.com/t/inventory-system-with-save-game/273721/5 "2022-01-20T13:40:15Z")

</div>

I understand much better now, Thank you for your time 🙂

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 20, 2022, 1:48pm UTC](https://forums.unrealengine.com/t/inventory-system-with-save-game/273721/6 "2022-01-20T13:48:42Z")

</div>

I’ll just add that because of how _cumbersome_ the native saving system can become (as the scope grows), amazing plugins were made, simplifying the whole process and adding tons of functionality:

> [@\[PLUGIN\] Savior](https://forums.unrealengine.com/t/plugin-savior-3/110080):
>
> UPDATE: [PDF Documentation can be found here](https://www.dropbox.com/scl/fi/fy5x4tbsqv0ngtto6e72i/Savior_PluginDocs.pdf?rlkey=5ktwd8w12j05wefxphoiudo8y&st=jg11qnpl&raw=1)! WHAT is Savior: This is a major update for the “Auto-Save Game” system I’ve been maintaining up on Unreal Marketplace for last couple years. Focused on performance and data reach, I’ve totally scrapped original code and wrote this version from scratch, implementing a fully custom serialization engine that made possible for me to achieve the goal of moving away from the built-in ‘FArchive’ system and it’s ’ \<\< ’ operator constraints. The reason…

---

<div class="post-metadata">

**Author:** ![Aumenn2003](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/aumenn2003/32/88718_2.png) [@Aumenn2003](https://forums.unrealengine.com/u/Aumenn2003)\
**Post date:** [January 20, 2022, 1:51pm UTC](https://forums.unrealengine.com/t/inventory-system-with-save-game/273721/7 "2022-01-20T13:51:59Z")

</div>

Thanks! I’ll look into it.
