Skip to content

Camera ​

Local camera state and screen-space conversions.

FunctionReturnsDescription
camera.get_position()vec3Camera world position
camera.get_view_angles()vec2Pitch and yaw in degrees (.x = pitch, .y = yaw, no roll)
camera.get_forward()vec3Unit vector pointing where the camera is looking
camera.get_fov()numberThe field of view from your game settings, in degrees (90 until it has been read). It does not change while you are scoped
camera.get_screen_size()vec2Screen dimensions: .x is width, .y is height
camera.world_to_screen(vec3)vec2 | nilPixel position with .x / .y, or nil if behind the camera. A point outside the view still gets coordinates, off the screen
lua
local pos = camera.world_to_screen(vec3(100, 200, 50))
if pos then
    draw.text(pos.x, pos.y, "here", 0xFFFFFFFF)
end

world_to_screen is also available as draw.world_to_screen. Both are the same function.