First Person Template HUD blueprint communication

Hi, I am new to blueprint scripting, and I have been making a game with the first person template, and adding my own features to it. I have already added my own ammo and ammo counter, as shown by the image below:

and the blueprint is here:

but after a while, If the player has been fighting baddies for a while, it looks like this:

and that looks really amateurish, and what I REALLY want is THIS:

I have this int variable called “Default Ammo” which goes down whenever the player fires, and when the player reloads, it goes back to 30.
I want to get the variable “Default Ammo” from the “FirstPersonCharacter” blueprint, and put it into the FirstPersonHUD blueprint like so:

but it keeps giving me compiler errors! I have googled forever and as of yet have not found the answer! I want to get this done as soon as possible, because some of my other planned gameplay mechanics rely on this. any help would be appreciated, and if needed, I can post more images later, and thank you for your time.

Your HUD is not part of your Character. It’s a separate class and is therefore not able to read this variable without a target.

I’m not 100% sure but there should be a node called “Get Player Character” inside of your HUD (with the context menu. This node is available from pretty much every class).
Now if that’s simply getting a character and you have a dropdown box that works technically. Just select player 0, cast it to your character and use it. For multiplayer or more complex systems this won’t cut it though.

Your second possibility is to “Get Owning Pawn” and cast that to your character. This will reliably provide the current character of the owner of this HUD,

35341-getcharacter2.png

I would also suggest to take a look at UMG, especially epics tutorial for this. It’s a UI builder with quite some cool functionality which makes creating your UI rather easy. Here’s the link to the tutorial:

Cheers! :slight_smile:

OH MY GOSH THANK YOU!

I ended up with this:

Great! :slight_smile:

Could you please accept the answer so other people know this is solved?

Thanks!