Hi, I’m doing a 2d slidescroller and I did a basic score system: when you pick a coin you score 10 when it arrives to score = 100 it resets to 0 and gives you health. Now I can see the values from print strings but I don’t know how I can see this value on a progress bar. The HUD with the progress bar is actually made and it shows to your screen so it’s working nice. I have seen some tutorials but they didn’t work. Thank you for your help! here are some photos about the score scripting.
Hey there, do you want to be able to see a text in front of the progress bar to see the progress like
Put a Overlay over your Progressbar and add a Text in there. Create a Binding for your Text. Read whatever you want from your Character refference (I assume you already have the Progressbar working). Format the Text however you want and pass it into the return node. Done.
nono I think I explained it bad sorry. I want a progress bar working not a text, I have the script of score working but not the progress bar
I want only a progress bar. I have the script of the score that is working (+10 every time that you take a coin) and I have that on a print string. But I don’t know how can I script my progress bar. So I only need some help on my progress bar blueprint .
So theres a pict of how it’s working right now (only want my progress bar working) thank you for the feedback you are always helping dude
You need to go to the progress bar in UMG and create a bind function for the progress value. The return value needs to be a value between 0.0 to 1.0, so you need to get your current number of coins and divide it with the maximum (which is 100).
Okey tomorrow I will tell you if it’s working thanks! (for now I mark you like the correct answer)
Oh Ok first you need a Character refference. Create a Character Variable in your Widget and expose it on Spawn. https://i.imgur.com/Imy4vSL.png (Save!)
If you go back to your Character where you create the Widget you will see that new pin. Pass “self” into it like that https://i.imgur.com/iXuV2mh.png
Back to your Widget in Design view create a Binding. https://i.imgur.com/u881x3G.png
And finally do the Calculation: https://i.imgur.com/PqH24yc.png
You don’t really need to expose on spawn the Character variable, you can get it on the Event Construct by using Get Owning Player Pawn and then cast it to the type of your character and save it there. Regarding your problems make sure you create a binding from the Percent and not from the isenabled. Usually when you create a new binding he names the function Get ProgressBar_78 Percent_0, something like that. Do even need to do any binding to Is Enabled? if you don’t then remove the binding.
Okey I did it and it still doesn’t work. In my binding, if I set it to float it gives me a error so I set it to boolean but it doesn’t work (but it compails ok) so here you can see in photos:
Can’t compile with float type:
Compile but no working boolean type:
Reference to player:
Score system Scirpt:
Buddy x) https://i.imgur.com/cUdZwk4.png
I did stil the same, wat im doing wrong now. Is all the same but now im using the progress binding and still don’t fill up wtf?
I don’t understand (I’m quite new on scripting :P) What are you saying about GetProgressBar_78? when I create one binding in percent it autoname’s GetPercent0. I did the divide by 100 and still don’t work and I don’t understand the GetOwningPlayerPawn (the cast yes). it still don’t work. :C
Thanks for ur help dude.
This is what i mean with owning player pawn:
When you bind the percent it should be something like:
Pay attention to the cast i do to the coins, if you divide coins / 100 you’ll get and integer value and that’s no good, you need to cast the coins first to float and only then do the division. Make sure to remove the binding with Is Enabled like this:
Also thaks you x)
Only 1 more question why it doesn’t let me get my coin variable look:
Get coin? (I think now the operation is fixed :D)
Here is the coin variable (I’m on my character bp):
Thank you so much! it’s working now.
That coin was just a local variable i created to exemplify, you want to use the Character reference and get the coins from there, like you where doing, then from the coins you do “To float” to cast it, then it’s the same as my example.
Good to know