We are going to get our items to appear on our screen in part 4.
We are first going to create a new input action and we are going to call it menu, and use the tab key to open it up.
We then are going to create a new player controller blueprint. We can place it in our players folder.
In the event graph we are going to look for our menu action we just created and create a widget. Well we need to create new commonUI CommonActivatableWidget and we will call it player menu.
We will add an overlay and bring in our InventoryMenuScreen(Variable).
We then are going to create new blueprint called PlayerMenuTabs. This will contain an Overlay, CommonBorder, Horizontal Box, and a Generic UI Button named Inventory Button (Variable).
We then will head back over to our PlayerMenu, where we will bring in our PlayerMenuTabs (Variable).
We now have to setup our player menu to listen for our input action.
We are first going to listen for our menu input and do a callback. This will create a new event. We will call it MenuInput.
Back over on our PlayerController make sure to select Player Menu as the widget we are creating.
We then are going to right click on our return value and promote it to a variable. This variable will be called Player Menu and we will add it to the viewport.
Back over to the player menu we are going to get the player controller and set the input mode to game and ui and then show our mouse cursor and set it to true. We are then are going to do in the inverese for when we close it and set the game mode to game only and hide the mouse cursor. We also are going to tell our Input action to consume our input.
So if we launch our game and press tab we will see our Inventory Menu
We then are going to head over to our InventoryMenuScreen to show the inventory. We are going to create a new function called Show Inventory. This is going to contain an inventory component and an inventory name. We are going to set the inventory component to an inventory component and set the inventory name to an inventory name and refresh when complete.
Let’s open up refresh. When we refresh we are going to clear the children from our inventory content wrap and as the event is constructed we are going to check if it is valid and if so we are going to get the keys from the inventory content and for each time we add something to the inventory we are going to create a new widget in the menu class with the name of the item and we will be adding it to our wrap box.
Back over in the Player Menu we are going to get our inventory menu screen and show our inventory. Next we will get our player character and cast it to our character and convert it to pure cast. We then will get our inventory component from the character. We now go back into the game and we can collect our item and it will appear in the inventory.
Next we are going to show our total of our items collected in our inventory.