[4.7.6] Why does World->OverlapMulti causes a hang in my FRunnable?
I made a subclass of FRunnable to handle AI calculations. Im not familiar with Multi Threading, so I was just setting up some tests at first.
I put in a World->OverlapMulti function to get a list of Actors around the AIPawn. Im using the following setup in Run to call it:
AIData->GetData().CycleCounter is set to 1 in a Timer in the controller, to ensure that the OverlapSphereOnPoint function(that handles the actual World->OverlapMulti call) isn't called too often.
My cycling code works, and OverlapSphereOnPoint is only called every other second.
But when it does the game hangs.
When testing with "Play in Editor" the hang is excessive, halting the game for several seconds. If I build the project and test outside of the editor the hang is much less(< a second but still noticeable).
The whole reason I want to multi thread the AI is so it doesn't lag out the other aspects of the game. And the weird thing is that if I just put that code into the AI Controller, there wouldn't be any hang at all. (I already have other actors with similar and much more frequent uses of World->OverlapMulti that don't produce any lag...)
Is it because Im trying to call World->OverlapMulti from a different thread?
If so, how am I suppose to achieve these kinds of searches from another thread?
asked Aug 05 '15 at 04:54 PM in C++ Programming
You can't do calls into the UObject system on other threads. You can only do gameplay from the Game thread.
answered Aug 05 '15 at 08:13 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here