I’m playing around with using flow fields for ai navigation. So far I am generating them on begin play so they never change. However I would like to update them to reflect changes in the world. Building them can sometimes take a bit of time so I would like to do this asynchronously. In order to do that I need some kind of copy of the world to pass to the helper thread to find all the blocking actors.
I’m currently trying:
UWorld* worldCopy = DuplicateObject(GetWorld(), GetWorld()->GetOuter());
Then inside the helper thread:
worldCopy->OverlapBlockingTestByChannel(FVector(worldPos.X, worldPos.Y, 20.f), FQuat(0.f, 0.f, 0.f, 1.f), ECollisionChannel::ECC_WorldStatic, collider)
That results in the exception:
Exception thrown at 0x000007FEB0ACCFB9 (UE4Editor-Engine.dll) in UE4Editor-Win64-DebugGame.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF. occurred
|>|UE4Editor-Crowd-Win64-DebugGame.dll!FFlowGenerationTask::DoWork() Line 47|C++|
| |UE4Editor-Crowd-Win64-DebugGame.dll!FAsyncTask::DoWork() Line 272|C++|
| |UE4Editor-Crowd-Win64-DebugGame.dll!FAsyncTask::DoThreadedWork() Line 296|C++|
I’m guessing my approach to copy the UWorld is incorrect, but I’m not sure what the correct one would be. Any advice?