I think when you use IsEmpty() or .Num() the system asumes MyArray is valid.
the pointer of an array is = the pointer of the first item.
if there is not array AT ALL then you cant tell how many elements it holds (.Num())
TArray<AActor*> Items;
AActor* ItemActor = Spawn bla bla bla;
Items.Add(ItemActor);
ItemActor->Destroy();
if(Items[0] != nullptr)
{
// ItemActor already destroyed completely, but still it is valid pointer in Array Reference
Items[0]->DoSomething(); // Crash, because ItemActor is actually not valid
}
Similarly, if we do something with Array when it’s values are not valid like this, it may crash.
So make sure to manually remove from array if actor is destroyed or pending destroy.
I can’t even check the array man. The engine thinks the array itself is a problem not it’s content. I can’t even do Items[0] or .IsEmpty() or .Num() == 0 or .IsValidIndex(0) on it.