RealDocs

AActor::IsInLevel

function Engine Since 4.0
#include "GameFramework/Actor.h"
Access: public Specifiers: ENGINE_APIconst

Description

Returns true if this actor is contained in the specified ULevel. Useful for filtering actors during level streaming operations or multi-level world setups.

Caveats & Gotchas

  • In worlds with sublevel streaming, an actor's level may differ from GetWorld()->PersistentLevel — always use this function rather than comparing GetLevel() directly if you want robust multi-level support.
  • Actors spawned at runtime (e.g. via SpawnActor) are placed in the level that was current at spawn time, which may not be the persistent level — this function is the reliable way to check.
  • Passing nullptr for TestLevel will always return false; guard against null ULevel pointers before calling.

Signature

ENGINE_API bool IsInLevel(const class ULevel *TestLevel) const

Parameters

Name Type Description Default
TestLevel const class ULevel* The level to test against.

Return Type

bool

Example

Check if an actor belongs to a streamed sublevel C++
void AMyManager::FilterActorsInLevel(ULevel* TargetLevel, TArray<AActor*>& OutActors)
{
    for (TActorIterator<AActor> It(GetWorld()); It; ++It)
    {
        if (It->IsInLevel(TargetLevel))
        {
            OutActors.Add(*It);
        }
    }
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.