Inventory Sytem UE5 Pt 5
We now are going to show a tooltip which allow us to drop items on the floor. We will now setup the interface for our tooltip.
We are going to use an image for our carrot. Once we download a carrot image we are going to go into the ItemData Table and go to thumbnail and let’s add our image. Save and close. Let’s hit play.
The next thing we are going to do is learn how to remove our item from our inventory. After we have opened up our inventory tab we do not want our player to continue moving around until we leave the tab screen. So we will disable input from our player character on the player controller. We then will turn off our hide cursor during capture.
Now once we close the tab we need to be able to turn the input back on. We will enable input from our player controller and we are targeting our player character.
Next we will create a submenu when we click on an item asking if we want to destroy it. Head over to the inventoryMenuSlot and let’s create function out of the override called OnMouseButtonDown.
We then are going to create a new UI that we are going to call the item tooltip.
In here we are going to have a overlay with a border, vertical box, ItemName(Variable) Textblock, ItemNameDescription(Variable) text block (set to auto-wrap), and a button.
In the graph we will create a variable itemName (name) and from the pre-construct we will get the item name from the item data table. Break the struct and get the itemname text and set the text as the display name and get the the item description text and set the text to the description name.
NOTE:Make sure the ItemName is Exposed on Spawn and IsEditable.
Now head back over to our button in the designer and select the on clicked event. This will bring us back over to the inventory where we will say once we have clicked the button we want to remove the item from our inventory.
We then create an event dispatcher under InventoryMenuSlot called SlotClicked. It says On Left Mouse Button down we get our screen space position from where we clicked and called the item name and position.
Next we are going to head to our InventoryMenuScreen and from our ShowToolTip Method that we are going to create we are going to get a valid tooltip and remove it from the parent and set it to blank, we will create a widget and add it to the viewport and set it’s position in the canvas slot.
Next time we will be dropping our item and removing it from our inventory.