Setting Ammo count on Begin Play is unnecessary

One of the things I noticed in this video is that he set the HUD’s Ammo count to 99 and the variable for Ammo as 60 and this caused some confusion when playing as we see the ammo count move from 99 to 59 when firing the first shot. That lead him to add a new pin to Begin Play to set the Ammo Count properly to 60. This is actually unnecessary. All you actually need to do is make sure the HUD’s default text and the variable’s default value are the same. So in this case, setting the HUD’s default text from 99 to 60 would have worked.

Also: This should basically be the rule for HUD elements. Once you are done testing your HUD, make sure you set the default values to the value you want it to be. For example, the Health Bar should be set to 1 at the beginning so you start at Full Health.

A bit late to reply, but I only just started on this last week.

Haven’t done this video yet, but I understand what you are saying.
The problem though with setting the hud text to a default, is that in this case, when you set it to 60, yes it starts at 60.
But if you have a game with multiple weapons that have different ammo counts, you run into the same problem as you mentioned, going from 60 to whatever the other weapons ammo count is.

What would be the better option, (besides having a basic weapon BP) to have the current ammo for a specific weapon, be set to the text as default, and have it start with max ammo as current ammo.

So basically like health, have a Max Ammo and a Current Ammo variable.
Where Current Ammo will be set to the HUD text at OnStart.

Privacy & Terms