Issues with blueprint structure

Hello-
I am starting to create a simple inventory display on my HUD. To keep it real simple, all I’m doing is displaying an integer, for now. I only have one kind of item in my inventory (iron, for now), so that makes sense, sort of.

If I grab a piece of iron, I increment an integer in my struct (Hud_data.numIron), and I display that value on the HUD. So I’m working with three blueprints here. Note that I started with the basic First Person project in the starter for UE4. The three blueprints are the FirstPersonCharacter, the FirstPersonHUD, and the blueprint struct I added, called HUD_Data. In FirstPersonCharacter I added the code which grabs an object and increments Hud_data.numIron. It seems to work. I even added a “ToText” call, which prints the value of Hud_data.numIron to the screen, and it is correct.

The real issues start in the blueprint FirstPersonHUD. This one has a reference to the Hud_data struct, extracts numIron and displays it on the HUD. It always displays zero, for some reason unknown to me.

I pass the exec from the existing code (which draws the crosshair in the middle of the HUD), and I call “Draw Text.” I set the “Text” parameter by using a getter on Hud_data, I break it, put numIron into a call to “ToText,” which goes into the “Text” parameter of “Draw Text.” But, as I said, all I get is zero. I was wondering if anyone sees anything wrong I’m doing here, or could point out things to look for. If anyone is interested I could attach a screenshot of the script. Thanks,
-Scott

Edit: I think what is missing is that, in the FirstPersonHUD blueprint, I am not properly initializing a reference to the FirstPersonCharacter, and its Hud_data struct. I’m working on the details now. Thanks.

Yes, please.

Always include a screenshot if possible, otherwise there could be many things behind this.
Maybe you created a second Struct instance but assigned a different one to DrawText etc.

Seen this question come up before a lot. Wonder if its because tutorials advocate Structs?
Remember its ok to just use simple variables, and then refactor your code better later on.

You can use the variable Categories editor option to informally structure variables for now.
Or just use a single Array-of-Actors as your inventory, and use Text-Tags to organize them.

It may be that simple BP classes are better than Structs for organizing everything anyway…
Structs can be a really convenient way to store data and pass it between various classes.
But ‘split out’ Structs to simpler variables when operating on them, to see what’s going on…

What I said in my edit above was right on the money.

There is a YouTube video by Red Tree Studios on a simple inventory system which helped me a lot. All I had to do was, within the FirstPersonHUD blueprint, was to add a reference to FirstPersonCharacter, and get the Hud_data from there. I think I would have had the same issue whether I was using a struct or a simple variable. I think it makes sense to put inventory in a struct, to keep things organized. Thanks for the replies,
-Scott