Blueprint Credit Hud Counter Problem

Umm got a Runaway hud counter. Soon as I start off the game, the hud credit counter works
but starts working at the wrong time. 15, 25, 65, 76, 97, 100, 200, 300 numbers just keep on
climbing up into the thousands which is incorrect behaviour because I haven’t even stepped into the trigger yet to pick up the credit off the ground to make the score refresh itself… so my score system is not working properly. The score counter is supposed to only refresh once after I pick the credit up.

But when I bind the counter code to the hud, the counter just keeps running and running
and not even waiting for me to first step into the trigger to refresh it.

I been at this for several hours now trying to track the cause as to why the counter is not
waiting for me to step into the trigger and then start updating. but only update itself once
each time I pick up a credit…

I would really appreciate it if someone can tell me how to CORRECT this issue so I can get the
counter score working properly.

The designer should have a drop-down list showing you what COUNTER TYPES that you want to bind into the hud for your text for those who don’t know how to build the code, and have an Advanced tab
on it for those who like to build the counters up from scratch. I’m not a BP programmer, so
I’m running into these type of problems in trying to build them myself because there’s no drop down
list for me to just select a counter type.

When you create a binding (by, in the widget designer, click the dropdown button showing create binding, remove binding)
That creates a function in the widget class which is called every frame.
The ‘intended use’ for this is to ‘look at’ variables of other classes, not perform variable modification as you are now. Every frame it will set the value of TotalCoins with the new value, while it should just be looking at the value on the class and converting it to string. So you should be setting the TotalCoins value on the class, not the widget.

That said, it is still not recommended to use the [function] binding because it is called every frame. The following Epic tutorial shows a more efficient way to do it.

However, I myself am not that used to event bindings and would make the following suggestions:
In the widget, create a string variable. This is the variable you bind the displayed text(number) to.
Then in the widget, either create an event or a function. When this is called, Either 1. you get the TotalCoins value from the character Or 2. just pass the value through the function, convert it to string and set the string variable with that string.
Now, in the character class, whenever you “pick up a coin” or whatever you’re doing, set the TotalCoins value in that class and then call the function of the widget, which I assume you have a reference to.
It’s very similar to the event binding system used in the docs but instead of binding, you manually call.
So in short; perform the variable modification on the character class, then update the widget.

I’m NOT at the advanced level so that tutorial you gave me from Epic is unfortunately not going to
work for my level. because you need to know how to build all the missing references that tutorial is using and I don’t have that knowledge, so the document is totally useless to me because I don’t have a high
enough level with constructing the blueprints to beable to use it…

The Epic tutorial shows you how to set up a progress health bar in three ways in the hud when I want to set up a simple credit text counter in the hud not a progress health bar system. So I think you given me the wrong tutorial.

Now In collecting up the credits I set the code up so each credit you pick up off the ground is assigned a random value between 1-100, it is NOT A FIXED VALUE of 5, 10 or 50 or 100. so each credit you pick up will be assigned any number value within that range. So all the hud was supposed to do was to just keep track of the random values for each credit picked up and just pass those values along into the main counter. This is how the credit score system was supposed to work. But it’s not working the way I wanted it to.

If you use print string I dont’ think you can size the font with that or change the location,
then you lose the counter off the screen after a few seconds. it doesn’t stay on for very long. That’s the reason why I tried to use the HUD Designer to put the counter in and bind it, thinking this would solve
the problem, but it didn’t solve the problem, only created a new one. I’m finding this to be too complicated to try to set up without having actual screenshots to show me how to set the blueprints up for doing this credit collection counter. Its not that easy because you have to also mess about with other settings
as well.
.

First I want to point out that the print string should only be used for debugging purposes or showing the *dev *various values while in the editor. In a packaged game, it does not even show up. So if you want to show text to the user, it should be through widget, or some kind of 3D visualization.

So, here’s some pictures with explanations. Read it all first without actually doing the things, then decide what you want.


Explanation:

  1. We create a string variable inside the widget.
  2. This allows us to bind the text of the text block widget to the string.
  3. We create an event (or if you prefer a function, do that), and add an Integer input to it. When this event is called, it’s going to take whatever int value is passed, convert it to string and set the Coin Text Variable to that string.

So, how do we call this Update Coin Value Event?
Well, the way you have it set up right now, is that when you overlap with CreditPick actor, that creates the widget. I would not do it that way and will show how I would do it, however I will at the end include an example of how you could keep your current way of doing things.

How I would do it:


Explanation:
Inside the FirstPersonCharacter, after the begin play event, we create the widget that shows the coins text. We should store it as a reference and we do that by creating a variable of that widget type. That can be easily done by right clicking on the return value and clicking ‘promote to variable’.

Now, it seems like you only want to show the coins text when you pick up a coin and after a short period hide it? If that is the case, the following graph works well. However, if you always want to show the coin text, just add the “add to viewport” after the begin play event and remove the “remove from parent” & “delay” nodes.


Explanation:
When the overlap happens, you cast to the player character and call the event/function. In this example it is an event. Note that the Delay node can not be used inside a function.

  1. We get the total Coins variable and set it to a new value which is the current value + a random 0-19 value.
  2. We add the coin widget to viewport and call the update coin value event, passing in the total coins value.
  3. we begin a delay function, which when completed, removes the coin widget from viewport. Note that it is not destroyed.
    If you go with this, things to delete from your current setup: The binding in the widget, Everything after & including the “create droidremain widget” nodes.

So, what if you want to keep your current setup.
In the First person character, ignore the creation of the widget after the begin play event. With the “addCoin” event or function, only include the setting of the TotalCoins variable, ignore everything else.
In the widget graph, instead of having an event with an int input, we just have an event with no input.
Instead, when the event happens, we get player character 0, cast to FirstPersonCharacter in your case, get the total coins value, set the text variable with that value.


If you go with this, things you need to change:
In the CreditsPick actor, before the delay node, call the Update Coin Value event in the widget.

Thanks so much for explaining it out to me and providing me some pics so I can actually see what’s going on in the blueprints because I knew you had to change several blueprints to set this up because that’s the way Unreal was designed to work… So I had some of the code linked ok, but not all of it was correct, was to be expected there would be some errors made due to inexperience as I’ve not had years of practice on Unreal. its new to me.

I think it pays for me to explain what I was trying to do in my game level…

REMOVE ALL WIDGETS - OOPS there goes my counters too.

I set it up that way to draw the coin widget back up again on the screen when touching the on overlap trigger to pick up the coins because I was also using the on overlap trigger for doing my game text dialog widgets with and it worked fine for displaying all the text widgets and then just removing the text from the screen using remove all widgets after the audio had finished playing. But when I used that node I also removed the counter widget from the screen as well, as the Droid Widget has got two counters in it, the Coins Counter and the Droids Remaining Counter.

I used remove all widgets only because I didn’t know how to use the remove from parent node. but I see from your screenshots that remove from parent needs a reference node to the actual widget you want to remove. And I think to get that reference you simply click on the widget name you want removed so its highlighted and then the widget should then show up in the node list when you type get to find the widget and then connect that up to remove from parent. and should leave the droid widget counter on the screen and not remove it.

USING ARRAYS

Once I get the basic dialog done in my level map. I can then move onto putting in some arrays for certain
npc’s you encounter in the level. I haven’t attempted doing an array with text widgets yet, I will do so once I know how to set up an simple array with a couple of text widgets with the on overlap trigger so you get a different text greeting popping up on the screen everytime you step into the trigger.

I just need to know how to set up the array for this. Once I know how to set an array up, You can then use that array for getting your npc’s to give you different kinds of greetings when you step
into the trigger . Like Hello, how are you, Nice day we are having. as my game has voice
audio and text in it.

It is critical that I can set up an array now with the text widgets in Unreal Engine because I had structured my game all around arrays in my windows script code for doing dialog and for everything else in the game… As I have got nearly two thousand arrays in the windows script code and that was needed for
doing all the dialog branching of all the party members of the game and all the storyline events.
loot rewards and so on. as its an interactive dialog rpg game.

So the array system is the main nerve centre, its the main foundation that makes everything all tick. That’s the reason why I want to put in the arrays in now for Unreal. as I’m translating all my code over from Windows Script now into the Unreal Engine Blueprints system. That’s why I been asking for help on here to help me to translate my own code into unreal Engine blueprint code.

DROID REMAIN COUNTER: For Droids Remaining, I simply wanted the Weapons trace gun to destroy the droid after shooting its health bar all down to Empty and then destroy the actor then decrease the number down by one in the Droids Remaining Counter each time a spawned droid gets destroyed. at the moment that damage and destroy code and depleting the health bar widget is not in my weapons trace gun code. so the gun works but doesn’t hurt them or their health bar yet. So there’s some issues still going on with my level, but one by one I hope to beable to resolve these issues.