Skip to main content

World

The World namespace defines any engine extensions offering details of the game world. As with any other game-specific extension, all functions under this namespace return nil if the game does not support this functionality or if it is currently unavailable.

Raycasting

The RayCast function casts a ray between from and to and reports any occlusion in between.

table RayCastResult {
bool hit -- Whether or not a hit occured.
vec3? position -- If a hit had occured, the position at which it had occured.
Entity? entity -- If a hit had occured and it was with an entity, the relevant entity handle.
vec3? normal -- If a hit had occured, normal vector from the surface.
}
-- Ray cast channels.
--
int World.RAY_VISIBILITY -- Skip transparent surfaces, e.g. glass. If not supported falls back to any.
int World.RAY_BREAKABLE -- Skip penetrable surfaces, e.g. glass, players, wood. If not supported falls back to level.
int World.RAY_LEVEL -- Skip dynamic state, e.g. players but not solid glass. If not supported falls back to any.
int World.RAY_ALL -- Skip nothing. If not supported falls back to level.

-- Casts a ray between from and to and reports any occlusion in between, if engine cannot
-- cast a ray right now, returns nil. If the channel is not supported, will use the fallback logic.
--
RayCastResult? World.RayCast(vec3 from, vec3 to, int? channel)
Promise<RayCastResult> World.AsyncRayCast(vec3 from, vec3 to, int? channel)

-- Casts a ray between from and to and reports any occlusion in between, if engine cannot
-- cast a ray right now, returns nil. If the channel is not supported, will fail.
--
RayCastResult? World.RayCastStrict(vec3 from, vec3 to, int? channel)
Promise<RayCastResult> World.AsyncRayCastStrict(vec3 from, vec3 to, int? channel)

Level information

-- Gets the current level name, returns "" if unknown.
--
string World.GetLevelName()

-- Gets the current level descriptor, returns nil if unknown.
--
LevelInfo? World.GetLevel()

-- Converts from world coordinates to minimap coordinates, returns nil if the position is not on the minimap or unknown.
--
vec2? World.ToMinimap(vec3 pos)

-- Gets the current gravitational acceleration in cm/ms^2, which defaults to -0.000981.
--
float World.GetGravity()

-- Gets the position (xyz) and the radius (w) of the Battle Royale circle if relevant.
--
vec4? World.GetBRCircle()