Hi! If actor is in persistent level, I can find him like that:
for (TActorIterator<AActor> ActorItr(GetWorld()); ActorItr; ++ActorItr)
{
if (ActorItr->GetName() == "CharFaceModel0")
{
AActor *Pointer = *ActorItr;
paperDoll1Actor = Pointer;
break;
}
}
I do it inside
LatentInfo.ExecutionFunction
callback to make sure level is loaded before the search;
But if I stream level using UGameplayStatics::LoadStreamLevel and world composition is enabled, actor is not found.
Why is that so?
Is the level in question visible by the time you iterate the actors?
In the operator++ implementation of the TActorIteratorBase class there’s a check whether an Actor may actually be returned by the iterator. If an actor may not be returned, the operator will simply search for the next one and repeat until it finds something suitable or it reaches the end. For this check it calls CanIterateLevel and IsActorSuitable if the current Actor is a valid non-NULL pointer. The first one will only return true if the Level is visible (bIsVisible). The second just checks whether the actor is NOT pending kill. Both of these functions MUST be true or else the Actor will be skipped and never given to you in an iteration.
Thank you for the info, I’ll try and investigate more based on it. Yes, the level is visible, at least setToVosible is set tu true for LoadStreamLevel function.
Ah! I see now. When I use level stream, CharFaceModel0 gets appened extra index name, so I need to adjust my search. Hmmmm, I generally dislike the idea of referencing actors by name. But I guess, when using Streaming Levels, there is no other way around it