Main thread and thread

You cannot interact with game objects from any thread other than the main game thread. To do so, you need to queue a task to be executed in the game thread like this:



FGraphEventRef Task= FFunctionGraphTask::CreateAndDispatchWhenReady(&]()
{
	// Code placed here will run in the game thread
}, TStatId(), NULL, ENamedThreads::GameThread);

// If you want to wait for the code above to complete do this:
FTaskGraphInterface::Get().WaitUntilTaskCompletes(Task);


1 Like