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,
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.