[SOLVED] [Blueprint / UMG] Can't Acces Variable More Than Once ? Advice Please

Hey mates. Need a little advice or guidance or directions.
Been working on my inventory system. Works well. I am trying to make a description window pop up just item’s name and it’s short description written on it when player howers on the item in inventory. As an example here is one from Gothic 3:

https://i.ibb.co/mhZgYYq/10.jpg

I have came quite a bit into accomplishing that. But the thing is description is shown only first time player is hovering the item on the inventory. If I pull the mouse away and do it again it just gives no description. Here first and second time.

https://i.ibb.co/KxjwfCt/prob1.png

https://i.ibb.co/HTKpYjY/prob2.png

I have a simple inventory system. Inventory itself works quite robust and well. I am using this tutorial if you need to know:
https://www.youtube.com/watch?v=_U5V…M0sdVy&index=4

I have three widgets: Inventory; InventorySlot, ItemDescBox. InventorySlot is just a button, image and text that are binded to AddedItem variable (custom FInventoryItem type) Inventory just collects these slots into a window and updates the slots in it’s Event Graph. Here is Inventory’s Event Graph if it helps:

https://i.ibb.co/741BJgP/prob4.jpg

ItemDesBox is just an image and text on it binded to AddedItemDesc (same FInventoryItem type before).
I made a small addition in ItemSlot’s Event Graph with OnHowered and OnUnhowered ones. The OnHowered one simply draws the ItemDescBox and Sets over the AddedItem variable to AddedItemDesc variable of ItemDescBox since they are both essentially the same type. The OnUnHowered one simply hides the widget.

https://i.ibb.co/PMgQ5Hp/Prob3.jpg

But like I explained this only works the first time. After that it always is returning nothing. What is it you think maybe causing this ? I have tried for 2 days but I am no master of UE4. Wanted to ask it. Also if you have any advices in general and tutorials you wanna suggets, I would like to hear them too.
I am using UE4.18.3
Thanks.

Here’s what’s happening, and this is a common mistake users make when working with widgets.
It’s the logic in the InventorySlot that causes the issue. The first time you hover over an item, the widget is created, displayed and properties are changed. So it displays properly. You then get rid of it by setting its visibility to hidden, but it still exists.
So the second time you hover over an item, a widget is created, displayed and the properties of the zero index - the first widget - are changed. The properties of the second widget that is now displayed are default.

In your case a possible fix could be to instead of setting visibility to hidden, you remove the widget from parent. That should mean that the widget has no references to it, and thus becomes garbage collected and thus deleted. However, I do not recommend that method since it is at best unreliable. I haven’t actually tried doing this so I don’t know if it would actually work. You could try it.

A better solution is to create the (and only one) description widget in the inventory widget. Then you could use a dispatcher in the inventoryslot that the inventory binds to, to update and display the description widget. Or a beginner friendly way is to just pass a reference of the description widget to the inventorySlot widget when they are created ( I assume the inventory creates the slots).

That would be a more proper way to display the description text although there’s still some pet-peeves of mine, such as the description being added to viewport. Let me know if you want to hear about it.

@ste1nar

Thanks a ton mate. It works just fine now :slight_smile:

https://i.ibb.co/WVzftGQ/thinbelly1.png

I used a Hud Blueprint to create the ItemDescBox (and also player health and staminabars) and Hide it right after they are created.

https://i.ibb.co/S7w3tdc/thinbelly2.jpg

Then I tried dispatchers but I couldn’t get it working it just for some reason ? Then I used casting as you mentioned when mouse is hovered to update the ItemDescBox via casting and also turning visibility on/off.

https://i.ibb.co/NpFyV1M/thinbelly3.jpg

Thanks a lot mate. I will now add more “eyecandy” to window. Also yeah I would like to hear about your set up if it is OK.