Use game instance variable in widget

I’ve looked a several videos and answers but I still cannot get this to work. I was there was a issue with the fact that the variable was an integer and tried making it a text but I was still having trouble.

I will include all screenshots as well.

I have a game instance variable called ‘Level’ which is of type integer and is set to ‘instance editable’ with a default value of 99.

I have a widget called ‘LevelWidget’ which has a TextBlock called TextBlock_LevelNumber with some default text.
(See designer screenshot)

In the graph of the widget I’m trying to get the instance variable called ‘InsLevel’ and display it in the widget. The code here compiles but it does not display anything. I’m thinking its because its and integer and not string variable but even if I change instance variable to text it still does not work.

When I try to connect SET output to ‘TextBlock Level Number’ I get ‘integer not compatible with text object’

Any Help would be greatly appreciated.

At the moment your blueprint would set the TextBlock reference itself (like if you wanted to replace it with a different TextBlock).
Seems like what you want to do is get your TextBlock, and then use a SetText (Text) node to change the words it displays.

Should this be done on the Event Contruct or on the Event Tick?

Also, is the cast to Game Instance and the rest of the blueprint correct?

Sorry, I also changed the textblock to and Editable Text block.

1 Like

If you need it to update every tick then you should look at Property Binding, otherwise on Construct makes more sense.

Great thanks.