Skip to content

The World API

World is how a script reaches everything beyond its own entity. It has two parts, methods on the world itself, and subsystem properties that group related functionality.

Entity Pickup = World.SpawnPrefab("/Game/Prefabs/Coin", new FVector3(0, 1, 0));
World.Physics.AddImpulse(Pickup, new FVector3(0, 5, 0)); // a subsystem

Each subsystem is a property on World.

PropertyWhat it does
World.RegistryThe component store, with Get<T>, Emplace<T>, views, signals. See Entities & Components.
World.PhysicsForces, velocities, raycasts, overlaps. See Physics & Collisions.
World.NavigationPathfinding and agent movement over the navmesh.
World.UIScreen-space RmlUi documents. See User Interface.
World.MessagesThe gameplay message bus. See Events.
World.NetNetwork role and replication state. See Networking.
World.DrawDebug drawing (Development and Debug builds only).
CallResult
World.SpawnPrefab(path)Instantiates a prefab, returns its root Entity
World.SpawnPrefab(path, location, rotation?, parent?)Same, placed (and optionally parented) in one call
World.SpawnProjectile(origin, velocity, damage?, lifetime?)Fires a swept projectile entity (see Physics)
World.DuplicateEntity(entity)Deep-copies an entity and its children, returns the new root
World.DestroyEntity(entity)Removes the entity
World.GetEntityByName(name)First entity with that name (Entity.Null if none)
World.GetEntityByTag(tag)First entity with that tag
World.EntityHasTag(entity, tag)bool
World.GetEntityName(entity)The entity’s name
World.GetNumEntities()Count of live entities
Entity Player = World.GetEntityByName("Player");
if (!Player.IsNull)
{
World.SetEntityRotation(Player, FQuat.Identity);
}

To create entities from nothing rather than from a prefab, use a world system, whose context exposes Create() / Destroy(entity).

CallResult
World.GetEntityLocation(entity) / World.SetEntityLocation(entity, v)FVector3
World.SetEntityRotation(entity, q)sets rotation
World.TranslateEntity(entity, delta)moves by a world-space delta

For an entity you act on every frame, prefer caching its STransformComponent via World.Registry.Get<STransformComponent>(entity) and calling its methods directly, same as Transform does for your own entity.

CallResult
World.SetParent(child, parent)Reparents child (preserving world transform)
World.DetachFromParent(entity)Detaches to the world root
World.GetParent(entity)The parent, or Entity.Null
World.GetRootEntity(entity)The top of the entity’s tree
CallReturns
World.DeltaTimeSeconds since the last frame
World.ElapsedTimeSeconds since the world was created

OnUpdate already receives DeltaTime as its argument; World.DeltaTime is there for code reached outside a hook.

Anything you can do to your own entity’s components, you can do to another’s through World.Registry, passing that entity.

Entity Door = World.GetEntityByName("Door");
SStaticMeshComponent Mesh = World.Registry.Get<SStaticMeshComponent>(Door);

To call into another entity’s script, fetch its instance by type.

Health? H = World.Registry.GetScript<Health>(Door);
H?.ApplyDamage(10);

GetScript<T> returns the live managed instance (or null), so you call its public methods directly, with no marshalling. See Events for decoupled communication that doesn’t need a direct reference.

World.Draw draws shapes for tuning and visualization. The draws are no-ops in Shipping builds, and a Duration of 0 draws for a single frame.

FVector4 Red = new FVector4(1, 0, 0, 1);
World.Draw.Sphere(Transform.GetWorldLocation(), 0.5f, Red);
World.Draw.Line(a, b, Red, Thickness: 2.0f, Duration: 1.0f);

The World.Draw methods are Line, Sphere, Box, and Text (screen-space).