Camera
Local camera state and screen-space conversions.
| Function | Returns | Description |
|---|---|---|
camera.get_position() | vec3 | Camera world position |
camera.get_view_angles() | vec2 | Pitch and yaw in degrees (.x = pitch, .y = yaw, no roll) |
camera.get_forward() | vec3 | Unit vector pointing where the camera is looking |
camera.get_fov() | number | The 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() | vec2 | Screen dimensions: .x is width, .y is height |
camera.world_to_screen(vec3) | vec2 | nil | Pixel 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)
endworld_to_screen is also available as draw.world_to_screen. Both are the same function.