Hello, I am trying to create a loot table that stores all the item that player obtain. Everything is working fine when the inventory widget are opened from beginning as shown on attached image 1, I put the inventory widget as semi transparent and marked with blue circle the item user obtain. Problem is, the inventory widget should only be accessible after pausing the game → main menu widget → inventory widget and if I go through this, it seems the item obtained will not be saved correctly like on attached image 2. I suspect that the item goes to “object inventory widget 1” and when I paused the game it goes to “object inventory widget 2”. Anyone has suggestion how to deal with kind of issue?
image 1
Try moving the loot table to an actor component. Have it separate from the widget.
Access the actor => actor component => loot table from many widgets later through a reference.
Just create an bp based on actor component and add in your variable probably of type array of your item struct. To make the code cleaner migtate your inventory array code (add, remove, swap item) to the component.
After changing the array call a refresh function on the widget.
So widget drag and drop could trigger the function within the actor component once it’s action ends it calls refresh on the widget.
Hi sorry for the delayed updated. To be honest I still don’t know how to implement your suggestion but it gives me the idea where the error is. So turns out when I created a main menu widget, I called ‘create widget’ which obviously create a new object. So when I change it with a reference to the widget I created on main character, it works. Although I am wondering if there is a much better way to reference it instead of using get all actor of class. Do you have any suggestion? Thank you in advance
Set the reference on construct and cache it to a variable, then in the on button pressed just use the reference instead if constantly calling get actir of class.