UMG: Updating score counter each frame

Not at all. I can’t sleep now anyway^^

Alright so you’re almost there. Once you used the “Get Gamemode” node you have the current gamemode. However the system is only acknowledging that you a gamemode instance. Not your gamemode so you can access all basic functions inside the gamemode class but not yours.

To solve this you have to use a “Cast To” node which basically checks which class your current gamemode is. The one you select in a dropdown menu inside of that node or something else (basically a branch for classes).

Just drag out a wire from the “Get Gamemode” node and search for “Cast To”. You should find “Cast To (your gamemode name)” in that list :wink:

Ah okay that makes sense. Should I be running the exec on the casting via the Event Tick? That’s how I have it set up at the moment, but still the UMG TextBlock remains at zero (I have the text content binded the same as I showed in the earlier image)

The bind should be either at the first time you run your UMG script storing it in a variable or you can very well do it every tick right before you show the number.

Remember to get the result of the cast to set it to your local variable or use that result to get your score from it.

I think I’m doing that properly but still not getting an update. I’ve decided to scrap the UMG binding and just use the “Set Text” node instead. Still no update though.

Many thanks Erasio!

Ah this won’t work since you’re setting the text only when you call “Event Construct” and not during the tick.

Try using the “Cast To MyGame” during “Event Tick”.

You either have to set your “score tracker” variable at the beginning with the result of this cast or do it repeatedly but you can’t just get the number during the construction :wink:

Okay I re-ordered like this:

Still not updating, but maybe I’m on the right track?

Are you sure you set your “Score Tracker” variable?

Maybe you should try using the “Set Text” function behind the cast pulling the object directly from that node. You could also get around the “Current Score” text variable.

I haven’t done a set node on the Score Tracker, I didn’t know I had to do that. What would I be setting it to / why is it necessary? Also re-organized without Current score variable:

Thanks!

You are using the “Score Tracker” variable to call your “Set Text” function.

Right now your “Score Tracker” variable is empty meaning the Editor will throw an error because you try to call a function of “none”.

Basically you’re trying to fill up a bucket but you only have a piece of paper telling you where to find the bucket. However someone forgot to write down where it should be so you just hold that piece of paper under the flowing water which seems to not be too effective.

A bit embarrassed now: just realized I had been running off the wrong value. I’ve been working from my original blueprint value from before I moved over to the game mode blueprint. Finally got it working! Erasio, you are my hero <3