Best way to bind variables from game instance?

Good evening. I need to create ui for my character’s characteristics so I created ui and now I need to get variables like stamina, endurance, etc. from game instance and bind it to text widget. I can create game instance variable in widget bp and create bind function where I’m getting stamina (for example).


But as I know bind is running every tick, so maybe there are ways to optimize it? Because for now I should create at least 15 functions with same logic like on screenshot.

1 Like

If you store the stats in the player ( because they are related to the player ), you can make the widget from the player, and just update it when the stats change, rather than on tick.

If you want to keep it like this, you could just pass a structure with the player stats in, and pop it open in the widget :slight_smile:

But the player is re-creating with every level loading, isn’t it? So I think it’s not the best practice to store these variables in it. Can you provide more information about second option? Do I need to create array in game instance and load it in widget bp?

Not an array, a struct

In the GI

Then you just pass the struct instead of a whole list of things.

One part of the widget does the reading

the rest can just use the variable

image

Oh, got it. And one more thing - there is a properties option in bind settings
image
where I can get value of some variables. Will I be able to get values of that structure here?

Or that! :slight_smile:

image

It works! The last question: will the value of variable from properties tab update every tick? Or it’s connected with another logic?

Tick :slight_smile:

1 Like

Nice! Thanks for your answers!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.