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.

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

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

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.

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?

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.

Hi I’m Roy,

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

1: Creating and Displaying UI | Unreal Engine Documentation

2: UMG UI Designer Quick Start Guide | Unreal Engine Documentation

sadly this is not an easy answer.

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.

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.

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.

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

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.

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)

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

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

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.