How do I display weapon ammo on screen?

Hi, so here is my problem:

I am currently displaying my character’s health on the HUD by casting to Base Character (because that’s where the health info is) and using “Get Player Character” as the object , and displaying my Score by casting to MyGameMode (because that’s where the score info is) and using Get Game Mode as the object…

What I want to do is display current Ammo on screen and the ammo information is on the Weapon class (because that’s where the ammo info is)… What should I use as the object on the “Get…”?

The attached image shows where I’m stuck.

Sorry for the newbie question!

It depends where you’re saving your weapon as a variable. If you saved weapon as a variable in the character blueprint, then say getplayercharacter → weapon → cast to weapon.

I’m sorry but I have no idea how I do that :frowning:

I just finished the “twin stick shooter” tutorial and figured I would increment it…

How do I save my weapon as a variable? I mean, I already have a “weapon” variable that I created on the Player Character blueprint to spawn the weapon on the character… Is that what you mean? I can’t get it from “GetPlayerCharacter” to cast to weapon…

Here is a picture of where I create the Weapon variable on the Player Character.

If this is not what you meant, can you tell me how to create this variable that I can cast on weapon?


Assuming that your ammo is stored in your weapon as a variable, then the first answer is right. You need to cast the character to whatever the name of the character blueprint is, then get the weapon, then if needed cast the weapon to weapon.

This probably doesn’t make much since, but think of it like this.

Casting is pretty much telling the blueprint what type of object the input is.