Working with pointers in Unreal, I quickly got into the habit of validating them before using them. In a project with lots of spawned and deleted Actors the validation itself crashes my game. How would I resolve this?
TArray<AActor*> SpawnedActors = {...};
for (size_t i = 0; i < SpawnedActors.Num(); i++)
{
//Valid?
if (!SpawnedActors[i]) continue;
if (!SpawnedActors[i]->IsValidLowLevel()) continue;
if (!IsValid(SpawnedActors[i])) continue; // <-- This sometimes causes a crash!
if (SpawnedActors[i]->IsPendingKill()) continue;
if (SpawnedActors[i]->IsActorBeingDestroyed()) continue;
}
Thank you and best regards,
Simon