Download

Multi-thread with Blueprint Implemented Functions

I’m loading a lot of stuff outside of the project in runtime when my game begins and I don’t want the player to wait during a fade or have the game lags, so I need to make it load in a separate thread.

I know it would be best to implement this directly into C++, but there’s already a lot of specific nodes that I can’t simply redo.

Is there a way to create the separate thread inside C++, call the Blueprint Implemented Event and then notify when it ends?

Thanks in advance.

The easiest way to call into blueprint graphs from C++ is to have a C++ base class or interface for your BP classes. Declare UFUNCTIONS as BlueprintImplementableEvents, implement them in the BP, then in C++ you can get a reference to an instance of your BP class, cast to the base class or the interface, and call the function.

It’s also possible to call arbitrary BP functions and events from C++ if you know the function name and signature, but that’s more of a pain.

You may run into thread safety problems if you actually do this. Depends what you’re actually trying to accomplish.