Can't take correct value inside struct

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):

And this is my hud where i tried to print the value (but it only prints 0):

The only item i have it’s inside inventory slot number 0

Hello ,

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 also have a few questions for you that will help narrow down what issue it is that you may be experiencing.

Quick questions:

  1. Could you try the example above and let me know if this works on your end?
  2. Could you go through the project and make sure that your struct is not being set somewhere else (effectively overriding it)?
  3. Could you try double checking that the blueprint that is setting the struct is firing off as it should be?

I did as you have said and it give me 2 on tick. I tried to check if insiede the item blueprint itself the struct work but nothing… it gives me 0

This is how I did it:

I directly got the struct variable and printed it (directly inside the item blueprint)

Hello ,

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.

Hello ,

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.

Thank you.

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?

Hello ,

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.

I tried creating the struct inside the event graph and set it on tick… and it seams to work.

I still have a problem: even if my struct now get the right value there is still something that doesnt work…

This is how i set the inventory slot’s variables:

And this is how i call them inside the slot:

But for some reason the stack number value is not printed correctly, it is 0 everytime!

Hello ,

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.