I have a 2 players local 2D game where they collect apples and they get 10 points per.
I have a widget that is called when 100 total points are reached - an Endgame widget. That one part works.
The problem:
I wanted to display each player’s points using a progress bar. This is the function (for players’ 1 points):
This would otherwise work if I had converted it to text, for example (minus the int/int).
And then I have the progress bars, the % is bound to the function obviously (players’ 1 points bound to the first progress bar, players’ 2 points bound to the second)
Yet when the widget appears, the progress bars stay empty - although both players have individual points equal to a multiple of 10. I’ve tried this before and it didn’t work that one time either so I just gave up and the in-game UI is just text - pretty unappealing right?
The progress bar goes from 0 to 1, from 0% to 100%. If you are dividing your points by 1 you are getting as a result your points, making the division redundant and getting always a number >1.
You should divide 1 by your total so you get the value of each item.
e.g.
If you need 10 items, then divide 1/10 so each item has a value of .1
And multiply this by your picked items so your bar fills.
Naturally, I know dividing anything by 1 equals the same - I had the second players’ points divided by 100. I just forgot to change it in the example I’ve given you.
However, the result was the same. I will now try what Sage suggested.
I have divided them by 100 instead of - when the widget was called Player 1 had 30 points which / 100 = 0.3. The bar stayed the same though. I know it should have worked. It just doesn’t though.
Screen shot of this? Did you happen to divide your integer 30 by 100 giving you a value of 0.3 as an integer which would have then been rounded to 0 and you subsequently converted that to a float to plug into the binding?
A lot of the time when I have the same issue, I add a node in the binding blueprint because usually when there is no nodes between Get Percent 0 and Return Node, it doesn’t work. So try adding like instead of getting a ref, casting to the ref or casting to ThirdPersonCharacter and then getting “Game Ctrl BP”.