Chaos physics crashes while trying to execute AsyncPhysicsTick over an actor that was unloaded by Word Partition

JIC Someone else runs into this, I made it work. This is my - humble -fix:
You can either implement this in a base BP + C++ actor (AsyncPhysicsWorldPartitionedActor.h or similar) and or just add three nodes to your existing actors and two methods on a C++ function library.
First add this two functions in C++. I added them in a library but you can add them in your base actor (Just replace “actor” by “this”):

CPP_LosBlueprintFunctionLibrary.h:

UFUNCTION(BlueprintCallable, Category = "AsyncPhysics", meta = (DisplayName = "UnregisterAsyncPhysicsActor"))
static void UnregisterAsyncPhysicsActor(AActor* actor);

UFUNCTION(BlueprintCallable, Category = "AsyncPhysics", meta = (DisplayName = "RegisterAsyncPhysicsActor"))
static void RegisterAsyncPhysicsActor(AActor* actor);

CPP_LosBlueprintFunctionLibrary.cpp

void UCPP_LosBlueprintFunctionLibrary::UnregisterAsyncPhysicsActor(AActor* actor)
{
    if (FPhysScene_Chaos* Scene = static_cast<FPhysScene_Chaos*>(actor->GetWorld()->GetPhysicsScene()))
    {
        Scene->UnregisterAsyncPhysicsTickActor(actor);
    }
}

void UCPP_LosBlueprintFunctionLibrary::RegisterAsyncPhysicsActor(AActor* actor)
{
    if (FPhysScene_Chaos* Scene = static_cast<FPhysScene_Chaos*>(actor->GetWorld()->GetPhysicsScene()))
    {
        Scene->RegisterAsyncPhysicsTickActor(actor);
    }
}

Then just add this to your async physics actor begin and end nodes, and you should be fine.

4 Likes