Skip to main content

Camera

Global Methods

Camera.GetPosition()

Gets the current position of the camera.

Example usage:

print(Camera.GetPosition())

Camera.WorldToScreen(pos: vec3): vec2

Converts world coordinates to screen coordinates. If the world position provided is on the screen, it will return a vec2 with the screen coordinates of that world position. If the world position is off-screen, it will return nil.

Example usage that draws a circle at a specified position:

Event.Add("OnRender", function()
local pos = vec3(1000, 1000, 1000)
local screen_pos = Camera.WorldToScreen(pos)
if screen_pos then
-- Draw a circle on the position if it is on the screen
Render.FillCircle(pos, 20, 24, vec4(1.0, 1.0, 1.0, 1.0))
end
end)

Camera.SetFOV(value: number)

Sets the FOV of the camera. The default value is 1.

Example usage:

Camera.SetFOV(1.5)

Camera.GetFOV(): number

Gets the current FOV of the camera.

Example usage:

print(Camera.GetFOV())

Camera.SpawnShake(type: CameraShakeType, position: vec3, amplitude: vec3, freq: float, falloff: float, time: float, radialBlur: float): void

Spawns a camera shake effect at the specified position.

Parameters:

  • type: CameraShakeType - The type of camera shake (see CameraShakeType)
  • position: vec3 - The position where the shake originates from
  • amplitude: vec3 - The amplitude of the shake in each axis
  • freq: float - The frequency of the shake
  • falloff: float - The falloff distance for the shake effect
  • time: float - The duration of the shake effect in seconds
  • radialBlur: float - The radial blur intensity

Example:

-- Spawn a spatial translation shake at an explosion position
Camera.SpawnShake(CameraShakeType.SpatialTranslation, vec3(1000, 100, 2000), vec3(1.0, 1.0, 1.0), 5.0, 10.0, 2.0, 0.5)

-- Spawn an absolute rotation shake
Camera.SpawnShake(CameraShakeType.AbsoluteRotation, vec3(0, 0, 0), vec3(0.5, 0.5, 0.5), 3.0, 15.0, 1.5, 0.3)