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"

I'm having issues updating the UI


I'm new to Unreal and am making a game to practice what I've learned and am stuck on an issue involving the UI. I have a float variable in a blueprint that keeps track of the score and I would like to have this score shown in the UI.

I casted to a blueprint I needed data from and then saved that variable. I then binded the textblock and created a function to get the score.

alt text alt text alt text

Does this all look correct and if so what steps can I take in order to update the UI?

Product Version: UE 4.19
binded.png (36.5 kB)
bindedfunction.png (43.0 kB)
eventgraph.png (66.6 kB)
more ▼

asked Jun 19 '18 at 08:56 PM in Blueprint Scripting

avatar image

16 3 5

avatar image shotty46290 Jun 19 '18 at 10:16 PM

I don't think I am understanding your question. Why is it doing wrong? The UI will update the variable, as long as it is being changed inside where you are pulling it from. so if coins give you points, and you go and pick up a coin, and add that score to your playerchar that you are casting too. The UI will update it by itself

avatar image CWolf93 Jun 19 '18 at 10:25 PM

My score variable itself is working and I can print out a string to see that, but apart from when the game starts up the UI never changes.

avatar image shotty46290 Jun 20 '18 at 12:47 AM

Have you put a print string on the cast making sure the cast is not failing? Also did you make sure to bind the function in the designer tab?

avatar image shotty46290 Jun 20 '18 at 01:02 AM

So I used the third person template and took some screen shots of what I did. you used the get player pawn, maybe that is why it is failing? what I did was get my controller, and then get the pawn it was controlling, then casted to it. Here is the screen shot. I also tested, and the number counted up on the UI. You will probably have to zoom into see it well, since I spanned it across my 3 screens to put it into 1 picture.

alt text

avatar image CWolf93 Jun 20 '18 at 03:31 PM

Thanks for all of the help. I have pretty much what you have (just changed the get controller/pawn to what you had) but I still can't get it to work. The score is definitely updating behind the scenes but the UI still wont update. I'm thinking I set something else up in an unconventional way and that's what's causing my issue.

avatar image CWolf93 Jun 20 '18 at 03:39 PM

I think I'm on to something, if I have the blueprint that keeps track of my Score variable auto possess my player the score updates perfectly. Unfortunately, doing that also changes the camera view so I'll have to find something similar that works.

avatar image CWolf93 Jun 20 '18 at 03:35 PM

I put a string on the cast and the functions is binded in the designer tab.

If I change the text in the designer tab to anything the score variable shows as 0 on the UI on startup. I'm not sure where this 0 comes from as I can change the default value for Score and it still becomes 0.

avatar image Roy Jun 20 '18 at 01:15 AM

Hi I'm Roy,

follow this links, I'm pretty sure that you'll learn what you need from it.

1: https://docs.unrealengine.com/en-us/Engine/UMG/HowTo/CreatingWidgets

2: https://docs.unrealengine.com/en-us/Engine/UMG/QuickStart

sadly this is not an easy answer.

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

2 answers: sort voted first

Where is this widget created, a common issue is having the widget created before the class you are casting to in execution. Which will leave your reference variable blank because event construct happened before "claw1" exists in the game causing the cast to fail. Try plugging a print string into cast failed on the Cast To Claw1 node.

Good luck

more ▼

answered Jun 20 '18 at 05:07 PM

avatar image

215 4 4 6

avatar image CWolf93 Jun 20 '18 at 05:31 PM

Fortunately I was able to get this working by checking "Auto Posess Player" on the bp class controlling this variable. I'm just figuring out how to avoid switching the camera when doing this via BP now.

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

I don't like binding. If you're looking for a more efficient way to update your UI widget here's what I suggest.

After you create your widget (Ex: In your character), promote it to a variable like this: (I'll call it MyUI)

alt text

In your widget make the score text widget Variable so we can access it in our blueprint.

alt text

Next we'll create an event in our widget blueprint which we can call from our character to update the score whenever we need.

alt text

Finally in your character BP after you update the score you can call the event so the widget updates the score using the MyUI variable we made when we created the widget.

alt text

createwidget.png (67.3 kB)
textvariable.png (46.6 kB)
widgetbpevent.png (79.0 kB)
updatescore.png (107.7 kB)
more ▼

answered Jun 21 '18 at 12:26 AM

avatar image

490 4 7 13

(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