How do I subtract ammo from hud?

I’m trying to learn blueprint and UMG at the same time since they’re both intertwined, and I figured i would start with the tutorial in the documentation:

And I got to this step, #6:

At the end of the Spawn Projectile script following the Play Sound at Location node, set Ammo to equal Ammo - 1.

But theres no picture to show what to do and I tried a bunch of things but nothing worked and i’m at a loss as to what to do. Everything else works.

Hi, I think what they’re saying is to just take the Ammo variable, subtract 1 from it and set it as the new value for Ammo. It doesn’t make any changes to the HUD on its own if that’s what you were referring to.

I know thats what im supposed to do but I dont know what the node setup looks like. I did a set ammo node, then a minus node taking 1 away, then another set ammo to set the subtracted amount. I have no idea. whatever setup I do, it either shoots 1 bullet and no more, or it shoots an infinite amount. In C++ you just do var - 1; or var -= 1; or var–; in a while or for loop but Its a little more difficult for me to understand when im trying to subtract numbers with the visual nodes. As for the hud changing, It should change, the tutorial above #6 says:

“Our Health, Energy and Ammo values are now displayed on our HUD and reflect our current values from our Character Blueprint. Pressing Space will have the character jump and deplete Energy, pressing the Left Mouse Button will fire the weapon reducing our Ammo

so it should reduce it but I think that might be my fault, I had a little trouble with that section and I may have done something wrong so im going to just re-do it but i wanted to fix this variable thing first.

Alright, got it. So the visual setup in blueprints should look like this:

Alternatively, you can use the Decrement Int node as well if you’re certain that ammo will get reduced by only 1 per shot.

1 Like

Awesome! thank you so much for your help!

Happy to help! :slight_smile: