x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

PrintString to ProgressBar

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. alt text

alt text

alt text

Product Version: UE 4.12
Tags:
coinscript.png (145.8 kB)
coinscript2.png (168.8 kB)
coinhud.png (94.6 kB)
more ▼

asked Dec 19 '17 at 09:23 PM in Blueprint Scripting

avatar image

marcmas31
14 3 2 6

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Hey there, do you want to be able to see a text in front of the progress bar to see the progress like this?

more ▼

answered Dec 19 '17 at 09:35 PM

avatar image

xlar8or
6k 161 129 304

avatar image marcmas31 Dec 19 '17 at 10:18 PM

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 :D alt text

scoresystem.png (888.1 kB)
avatar image xlar8or Dec 19 '17 at 10:27 PM

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).

avatar image marcmas31 Dec 19 '17 at 10:33 PM

Okey tomorrow I will tell you if it's working thanks! (for now I mark you like the correct answer)

avatar image xlar8or Dec 20 '17 at 07:59 PM

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.

avatar image marcmas31 Dec 20 '17 at 10:40 PM

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

Coin script: https://i.imgur.com/BpXlg0S.png Division: https://i.imgur.com/XjSGz7z.png In game: https://i.imgur.com/QhzSYZV.png

Thanks for ur help dude.

avatar image xlar8or Dec 20 '17 at 10:49 PM

This is what i mean with owning player pawn:

alt text

When you bind the percent it should be something like:

alt text

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:

alt text

owning.png (150.4 kB)
coins.png (32.0 kB)
binding.png (29.1 kB)
avatar image marcmas31 Dec 20 '17 at 11:06 PM

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)

alt text

Here is the coin variable (I'm on my character bp):

alt text

getcoin.png (294.8 kB)
coinvariable.png (326.1 kB)
avatar image xlar8or Dec 20 '17 at 11:08 PM

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.

avatar image marcmas31 Dec 20 '17 at 11:33 PM

Thank you so much! :D it's working now. :D

avatar image xlar8or Dec 20 '17 at 11:34 PM

Good to know :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Dec 19 '17 at 09:51 PM

avatar image

Nachtmahr
6.9k 143 26 172

avatar image marcmas31 Dec 19 '17 at 10:15 PM

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

avatar image marcmas31 Dec 19 '17 at 10:21 PM

Here is a photo :D (I only want my progress bar be working) thank you :D alt text

scoresystem.png (888.1 kB)
avatar image Nachtmahr Dec 19 '17 at 10:34 PM

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

Thats it.

avatar image marcmas31 Dec 20 '17 at 07:41 PM

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: https://i.imgur.com/A2pOIcA.png

Compile but no working boolean type: https://i.imgur.com/ZCVq0XT.png

Reference to player: https://i.imgur.com/W7nyv1x.png

Score system Scirpt: https://i.imgur.com/BpXlg0S.png

ProgressBar: https://i.imgur.com/O8SCy9F.png

In game: https://i.imgur.com/QhzSYZV.png

avatar image Nachtmahr Dec 20 '17 at 09:35 PM
avatar image marcmas31 Dec 20 '17 at 10:32 PM

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?

avatar image marcmas31 Dec 20 '17 at 10:41 PM

Also thaks you x)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question