I’ve gotten object iterators working with some help from the forums and the excellent tutorial rama posted at https://wiki.unrealengine.com/Iterators:Object%26_Actor_Iterators,_Optional_Class_Scope_For_Faster_Search#Disadvantage_of_Object_Iterator , but I’m finding that by default, their scope is quite wide- if I follow that tutorial exactly and run something like this:
UWorld* YourGameWorld = //set this somehow, from another UObject or pass it in as parameter
TArray myArray;
for(TObjectIterator Itr; Itr; ++Itr)
{
//World Check
if(Itr->GetWorld() != YourGameWorld)
{
continue;
}
//now do stuff
myArray.Add(*Itr);
}
myArray will end up with every single USomeObject currently spawned in the world. If I run this from an actor inside a level (besides the persistent level), Is there any way I can restrict the results to only the instances of USomeOject that share a level with whoever is running the code?