I copied the inventory from “Inventory UI with UMG” project (inside the learn tab) and tried to add inside the inventory struct another value, an integer for stacking object. The problem is that if i set the integer inside the struct and try to print it inside the hud it give me 0 value any time! It seems that that the value inside the struct it’s always set to 0 even if i change it.
This is how i set the inventory struct (with the stack value set to 2):
I was unable to reproduce this issue on our end. I downloaded the project and add a new member to the struct that was indicated in your post. I then opened up my character blueprint and created a new struct variable that was base on the Inventor Struct. I then used a tick event to print out the value of the new struct member. The changes made to this value were reflected correctly with the print string. I have included my example below.
Example:
In this example you can see that the variable “StructVar” was the variable that I created base on the Inventory struct (this is shown on the left). You can also see that I added a new int member to the struct (the struct member being set to 2).
I would set a variable that is based on the struct and then I would just reference this struct variable via casting when I need to use it. This method is closer to the intended use of the struct. I hope that this information helps.
Example:
The example below is using the same variable that was set up in my last post.
We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.
Sorry if I didnt answered you before. I dont save the item struct inside the player character but inside the item itself… how should i call that way from it?
You could use the get all actors of class if you are trying to pull a reference from another blueprint and from there you could get a reference to the struct that you need.
From what I can see in the screen shots that you have provided it looks like you have two different instances of the struct (on in Pozza and the other in GameHud). You would need to cast to Pozza (where you’re setting the variable for “Stack Number”) and get the struct variable “Item Info” from that cast. From there you would would break the struct (item info) to gain access to the “Stack Number” variable that is being set in Pozza.