Counter on HUD not replacing original value

Hello!
I’m in school for game development and a new UE4 user. I have a very basic looking third person target practice game. I have a number of targets spread out across a landscape and when they’re shot, they are removed from view. I also have a HUD counter that counts each target when they’re hit and the counter works, but the number doesn’t replace the original value of 0. It just puts it on top. I will put screenshots to illustrate what I mean.

Here is the counter before anything is hit:

341804-target-0.png

Here is the counter after the first target is hit:

341805-target-0-1.png

As you can see, the 0 is still shown even after the 1 appears and they’re just stacked on top of each other.

I also have a couple blueprint images of the game mode, the target, and HUD.

Game Mode:

Target:

HUD:

I firmly believe I may have not included a node, or not done a blueprint correctly in the “UpdateHUDwithTargetsHit” block in the Game Mode blueprint, but I’m not sure what I did wrong. Any help will be appreciated!

Thanks,

From the first screenshots, I’d guess you are somehow instantiating 2 versions of the HUD, and only updating one of them. Could you try to disconnect the logic from your gamemode begin play function, and see if a HUD still appears?

Tried that. It did show the HUD without the beginplay node connected, but it wasn’t counting anything. So I think there’s another beginplay setup somewhere else.

Hey, you don’t need to cast in your HUD and for your target it should be enough to cast once at BeginPlay. You could try this (only used the shown Events):
W_HUD:

BP_Target:

FirstPersonGameMode:

That should work.

Ok…I just have a question. How do you get the node that just has a blue connection on one side and a purple on the other side?

You drag of the blue pin and then type “ToString”

Ok…Just did all of the changes you suggested and it’s still not working properly. It’s also counting the same target multiple times (probably because the target was supposed to move out of view once it’s hit…I had it set to go below the terrain before I changed to your suggestion.)

Well, try it yourself (zipped project with targets moving into the ground):

So I just opened your file and it works. I looked at all the blueprints and they’re exactly the same as mine, so I don’t know why it’s behaving differently in my file. I would share it with you, but my content folder is over 10 GB and I don’t want you to have to download something that large for this.

“counting the same target multiple times” like a random amount or exactly two times?

like it counts the same target I’m hitting for as many times as it’s being hit. when I playtested it after changing the blueprints, I hit the first target 36 times.

Did you change anything else? Is it really the same, like how do you get your text? Or did you copy my solution? Is there a function in your projectile which could cause this?

I didn’t change anything. The only thing I can think of is that my game is in third person mode, not first person like your setup. I can’t imagine that would make any difference, but even when I copy and pasted your nodes, I had to change your first person game mode refs to third person.

Are you using EventTick in Blueprints which are affecting your targets/character/gamemode? Is there something odd? How does your projectile look like? If you want me to have a closer look or test just those blueprints for your targets for yourself, you can migrate your blueprints to a new empty project. To copy/pack a project, click on File-PackageProject-ZipUpProject

I found the issue…there was an additional add widget to viewport in the level blueprint that was duplicating the HUD instance.

I found the issue! There was an additional Add Widget to Viewport blueprint in the level blueprint I forgot I made a while back.