AActor::GetLevel
#include "GameFramework/Actor.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallable
Description
Returns the ULevel that contains this actor. Use this when you need to query or modify level-specific state, or when performing cross-level checks.
Caveats & Gotchas
- • Returns the level the actor is owned by at spawn time — actors do not move between levels at runtime. For level streaming scenarios, the returned level may be a sublevel rather than the persistent level.
- • Do not confuse with GetWorld()->GetCurrentLevel(); that returns the currently active level for spawning, not the level this actor belongs to.
Signature
ULevel* GetLevel() const Return Type
ULevel* Example
Check if actor is in a specific level C++
ULevel* MyLevel = MyActor->GetLevel();
if (MyLevel)
{
UE_LOG(LogTemp, Log, TEXT("Actor is in level: %s"), *MyLevel->GetName());
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?