I'm making a horror game #10

Updating the quick wheel items


8/12/20233 min read

Welcome to the 10th I'm making a horror game post. During today's stream, I focused on trying to update the Quick Wheel items. Prior to the stream, the items assigned to the Quick Wheel didn't update - this was a problem because the player needs correct information when opening the Quick Wheel.

The quick wheel menu didn't update according to the inventory's status. If the user assigned an item to one of the quick wheel slots, then used said item, the quick wheel slot didn't show the correct information. It had the wrong quantity, it didn't display the "is equipped" icon, and it also didn't disappear if the item was no longer in the inventory.

This is definitely not ideal, as the user needs to know how much of an item is left when opening the quick wheel menu. A lot of this came down to communicating a change to inventory items, and sometimes order of operations.



The first thing I did was look at how the different blueprints exchanged information. I quickly found out that there was no place in the logic where the Quick Wheel slots were updated after a change was made to inventory items.

Prior to today, the Quick Wheel slot was assigned an item when the player clicked on it. The Item data was saved in an "Assigned Item" array, but it was never updated after that.

To solve this, each time the Quick Wheel is open, I go through the array and find the Inventory item that shares the same ID as the assigned it. Once found, I update the Quick Wheel Item Slot Info, that way it's always displaying the correct information.

Thanks for reading!

There's still more to fix, such as the "Equipped" status being shown in the Quick Wheel, as well as supporting assigning cards to the Quick Wheel, but let's take it one step at a time.

I'll see you for part #11!

The other thing we fixed was the removal of items from the Quick Wheel when they are removed from the inventory. The solution to this problem was a bit more involved. It meant keeping track of the Inventory items, while also making sure the Assigned Items array was updated with the correct information, specifically the item ID (as that's how we identify which Inventory Item is assigned to that slot.)

To solve this problem, we first have to find the item in our Assigned Item array (using the ID) and set the array element to null (because of the way the Quick Wheel is built, I can't just delete it.) After setting it to null, we update the given slot's info so it shows the proper info (or non-info.)

After "removing" this item from the Assigned Items array, we must update the remaining item IDs so they still match with the inventory item IDs. The next step is to update the remaining inventory IDs to make up for the loss of an index (since the item has been removed.)

All that's needed here is to cycle through the Items inventory array and adjust their ID by subtracting 1. Since we removed an index, we decrease all remaining IDs by 1, unless their ID would be -1, at which point it's assumed that it is 0 and should stay at 0.