Skip to content

Camera ​

Local camera state and screen-space conversions.

FunctionReturnsDescription
camera.get_position()vec3Camera world position
camera.get_view_angles()vec3Pitch, yaw, roll in degrees
camera.get_forward()vec3Unit vector pointing where camera is looking
camera.get_fov()numberField of view in degrees
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
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. Same function.

Not affiliated with Valve Corporation.