Download

Run blueprint in background

So how can i make bp that runs in background for games tech tree.
Example i click on button and research will be done after 10min. How can i make that these 10 mins also run in background when player is doing other stuff.?

You can just use a delay node

All blueprints run in the background.

1 Like

Or a Timer if you need to also pause / unpause and see how much time has passed / remains:

Timer is a glorified Delay but with features. You could have each Tech as an actor component running a timer and being a part of the Techtree actor. In case you need more than Research happen simultaneously. If not, one timer is enough. For something super simple, a Delay might do but you can’t record that if you want to save mid-research… Not without extra code, that is.

1 Like

If i close widget where it has started and open it again everything is set to default by my BP’s how can i run that function so when i close than open timer still runs on research?

Probably because you destroy the widget. Create it once and only show / hide it instead - it will retain values. One note - hidden widgets or widgets that are off-screen do not Tick. But their timers run, me thinks.

If i close widget where it has started and open it again

Normally, you do something along the lines of:


Also, it’s not a good idea to put too much logic in the widgets. Consider keeping logic in the actors or their components so you can take full advantage of inheritance. And use widgets for displaying stuff only - they can format raw data you pipe in.

Inheritance with widgets works OKish, it’s a bit wonky here and there.

I managed to get working everything opening and closing widget and function is till running and its all ok, but when i posses different character everything resets, even if i set visibility of widget to hidden.
Any ideas?

when i posses different character

If you run this script in the character, each character will have its own instance of the widget. Is this the case?

If so, perhaps it’d be a good idea to have it in the Player Controller instead. This way, only one instance exists, no script is duplicated and we keep accessing the same widget, regardless of the possession.

That’d make sense unless you swap controllers, too. Then the Game Mode would be next good place; and, if you fiddle with those as well, then the Game Instance. Or perhaps there’s should be a Research Actor Manager that owns the widget and handles the progress; the character access that.

Hard to advise since we know very little about the structure of the game. So far it’s a guessing game. :slight_smile: