Hello, I have a problem when calling a function SetActorLocation, SetWorldLocation and others from a separate thread (Whether it’s standard streams C ++ - std :: thread, or FRunnableThread and the like).
PS Problems with calling functions on the log - I do not have
You are not allowed to modify UObjects (thus AActors as well) from a separate thread!
You really should avoid even touching the UObject subsystem from another thread, it is not thread safe
Other threads are best used for raw data calculations.
The highest level data structure I’ve successfully used in multithreading is a USTRUCT which works great!
So I"d recommend doing all your calculations in the other thread,
but come back to the main game thread to actually use the results of your calculations, like setting Actor Location, spawning new actors, and things like that
You can still use multi threading, just save the final steps that involve UObjects for the main game thread.
As Rama says, game objects may only be modified on the game thread. Now, you can calculate the data on another thread and then apply it on the next tick for that actor. Also, the example you show is too light weight to benefit from being on another thread. The overhead of getting that data there will outweigh the benefit of calculating it on another thread.