#36 Toggle Inventory UI - How to Make a Ghost Hunting Game in Unreal
In this lesson, we continue working on the Inventory UI for our Unreal Engine 5 ghost hunting game. After creating the main inventory widget and the inventory slots, we now connect the UI more directly to the player workflow. The goal is to open and close the inventory during gameplay, display the picked-up items correctly, and decide how the player should behave while the inventory is open. First, we fix a small inventory slot issue from the previous setup. Because array indexes start at 0, we need to subtract 1 from the inventory length when looping through the slots. Without this fix, the UI can show an incorrect extra slot or item image. This is an important pattern to remember when working with arrays in Unreal Engine. After that, we create the main open and close logic inside the inventory component. We add a function to check if the inventory can be opened and use a player movement check to prevent the inventory from opening while the player is falling. Then we create the actual Open Close Inventory function. This function checks if the inventory is already open. If it is closed, we create the inventory widget, add it to the viewport, show the mouse cursor, and change the input mode. If it is already open, we remove the widget again and return to normal gameplay input. We also create a new Inventory input action and bind it to the inventory key. This allows the player to open and close the inventory during gameplay. During testing, we go through different input mode options and explain the difference between allowing the player to keep moving while the inventory is open or locking movement and camera control while the UI is active. For this, we use Show Mouse Cursor, Set Input Mode Game and UI, Set Ignore Look Input, and Set Ignore Move Input. This gives us two possible design choices. You can allow the player to move and look around while checking the inventory, which could be useful during a hunt. Or you can stop movement and camera control while the inventory is open, which makes the inventory feel more like a focused menu. The right choice depends on the style of your game. At the end, we test the workflow by picking up items and opening the inventory. The items now appear inside the inventory UI, and we can see the stacks update when more items are picked up. By the end of this video, the inventory can be opened and closed, the picked-up items appear in the UI, and the player input behavior while the inventory is open is prepared. What you will learn in this video: How to fix an inventory slot loop issue Why array length often needs minus one when using indexes How to create an Open Close Inventory function How to check if the inventory can be opened How to prevent opening the inventory while falling How to create an inventory input action How to add the inventory widget to the viewport How to remove the inventory widget again How to show the mouse cursor for UI interaction How to use Game and UI input mode How to stop player movement while the inventory is open How to stop camera look input while the inventory is open How to test picked-up items inside the inventory UI Chapters: 0:00 Intro & Inventory Workflow Goal 0:40 Fixing the Inventory Slot Loop Issue 2:47 Creating Open and Close Inventory Functions 3:15 Adding the Can Open Inventory Check 5:37 Building the Open Inventory Logic 7:20 Storing the Inventory Widget Reference 8:17 Setting Mouse Cursor and Input Mode 10:13 Building the Close Inventory Logic 11:19 Creating the Inventory Input Action 12:34 First Open and Close Test 13:35 Fixing the Input Mode Behavior 14:34 Blocking Look and Movement Input 16:40 Fixing Ignore Input Nodes 17:48 Testing Inventory Movement Options 18:04 Showing Picked-Up Items in the Inventory 19:05 Current Result & Next Step Course Goal: We are building a first-person ghost hunting horror game in Unreal Engine 5 step by step. Throughout this course, we will create a paranormal horror game prototype with multiplayer, player movement, flashlight mechanics, doors, light switches, fusebox logic, interaction UI, EMF Reader, thermometer, UV tools, Ghost Writing, inventory, evidence systems, ghost behavior, sanity, a journal, and a complete gameplay loop. #UnrealEngine5 #UE5 #UnrealEngine #GhostHuntingGame #HorrorGame #InventoryUI #InventorySystem #WidgetBlueprint #InputMode #UE5Blueprints #BlueprintTutorial #HorrorGameDevelopment #IndieGameDev #FirstPersonHorror #PhasmophobiaInspired
