UWorld
#include "Engine/World.h"
Access: public
Specifiers: UCLASS
Description
The top-level game world object. UWorld owns all actors, levels, the physics scene, the navigation system, and the timer manager. It is the primary context object — most gameplay operations that interact with the world (spawning actors, raycasting, etc.) require a UWorld pointer.
Signature
class UWorld : public UObject Caveats & Gotchas
- • In Unreal, there can be multiple UWorld instances simultaneously (game world, editor world, PIE world, preview worlds). Fetching the wrong one is a common source of bugs. Use `GEngine->GetWorldFromContextObject()` or `GetWorld()` on a valid actor or component.
- • Never store a raw `UWorld*` as a class member — always get it via `GetWorld()` when needed.
- • The timer manager (`GetTimerManager()`), line trace functions, and `SpawnActor()` are all accessed through UWorld.
Example
Spawning an actor and performing a line trace C++
UWorld* World = GetWorld();
if (!IsValid(World)) return;
// Spawn actor
FActorSpawnParameters Params;
AMyActor* NewActor = World->SpawnActor<AMyActor>(
AMyActor::StaticClass(), SpawnLocation, FRotator::ZeroRotator, Params);
// Line trace
FHitResult Hit;
FCollisionQueryParams QP;
QP.AddIgnoredActor(this);
bool bHit = World->LineTraceSingleByChannel(
Hit,
TraceStart,
TraceEnd,
ECC_Visibility,
QP
);
if (bHit)
{
UE_LOG(LogTemp, Log, TEXT("Hit: %s"), *Hit.GetActor()->GetName());
} Functions (10)
Transform 1 ▼
| Access | Type | Name |
|---|---|---|
| public | function | UWorld::SpawnActor |
Collision 4 ▼
| Access | Type | Name |
|---|---|---|
| public | function | UWorld::LineTraceMultiByChannel |
| public | function | UWorld::LineTraceSingleByChannel |
| public | function | UWorld::OverlapMultiByChannel |
| public | function | UWorld::SweepSingleByChannel |
Utility 5 ▼
| Access | Type | Name |
|---|---|---|
| public | function | UWorld::DestroyActor |
| public | function | UWorld::GetAuthGameMode |
| public | function | UWorld::GetGameState |
| public | function | UWorld::GetTimerManager |
| public | function | UWorld::GetTimeSeconds |
See Also
Version History
Introduced in: 1.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?