Trigger API Reference\DCEI Functions\Camera

void SetEnabledCameraClamp(bool set)

void SetEnabledCameraClamp(bool set)

Description


Toggles camera clamping. When clamped, camera movement will be restricted to inside the red square border displayed in the Terrain Window. In order to move the camera outside of this square, the camera must be unclamped first.

Parameters

Example Usage

local layout = GMUI.Layout.New({
    parent = DCEI.GetUiRootFrame(),
    name = "Standard/Button/Button",
})
DCEI.SetOnClickCallback(layout.Button, function()
    DCEI.SetEnabledCameraClamp(false)
end)

void SetEnabledCameraClampForPlayer(int player, bool set)

void SetEnabledCameraClampForPlayer(int player, bool set)

Description


Toggles camera clamping for the given player. When clamped, camera movement will be restricted to inside the red square border displayed in the Terrain Window. In order to move the camera outside of this square, the camera must be unclamped first.

Parameters

Example Usage

local layout = GMUI.Layout.New({
    parent = DCEI.GetUiRootFrame(),
    name = "Standard/Button/Button",
})
DCEI.SetOnClickCallback(layout.Button, function()
    DCEI.SetEnabledCameraClampForPlayer(1, true)
end)

void SetCameraFocusUnit(unit unit, float delay, float offsetX = 0, float offsetY = 0)

void SetCameraFocusUnit(unit unit, float delay, float offsetX = 0, float offsetY = 0)

Description


Sets a persistent camera focus on the given unit. Does not override previous focus, use ClearCameraFocusUnit to clear previous focus before setting a new focus.

Parameters

Example Usage

local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)

DCEI.SetCameraFocusUnit(unit, 3, 5, 5)

void ClearCameraFocusUnit()

void ClearCameraFocusUnit()

Description


Removes any active camera focus.

Example Usage

local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)

-- Focuses on area above unit over 2 seconds
DCEI.SetCameraFocusUnit(unit, 2, 0, 5)

-- Clears focus after 3 seconds
DCEI.TriggerAddTimerEventElapsed(function()
    DCEI.ClearCameraFocusUnit()
end, 3)

void SetCameraFocusUnitForPlayer(int player, unit unit, float delay, float offsetX = 0, float offsetY = 0)

void SetCameraFocusUnitForPlayer(int player, unit unit, float delay, float offsetX = 0, float offsetY = 0)

Description


Sets a persistent camera focus on the given unit for the given player. Does not override previous focus, use ClearCameraFocusUnitForPlayer to clear previous focus before setting a new focus.

Parameters

Example Usage

local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)

DCEI.SetCameraFocusUnitForPlayer(1, unit, 3, 5, 5)

void ClearCameraFocusUnitForPlayer(int player)

void ClearCameraFocusUnitForPlayer(int player)

Description


Removes any active camera focus for the given player.

Parameters

Example Usage

local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)

-- Focuses on area above unit over 2 seconds
DCEI.SetCameraFocusUnitForPlayer(1, unit, 2, 0, 5)

-- Clears focus after 3 seconds
DCEI.TriggerAddTimerEventElapsed(function()
    DCEI.ClearCameraFocusUnitForPlayer(1)
end, 3)

void SetCameraFocus(float x, float y, float duration = 1, bool useRealTime = False)

void SetCameraFocus(float x, float y, float duration = 1, bool useRealTime = False)

Description


Moves camera focus to the given coordinates.Use Game Time by default

Parameters

Example Usage

function MoveCamera(target_index, duration, options)
    target_index = target_index or ((cameras.current % 2) + 1)
    cameras.current = target_index

    local our_duration = duration or 0.5
    local camera = ShallowCopy(cameras[target_index])
    local use_game_time = true

    camera.x = camera.x + (options and options.x_offset or 0)
    camera.y = camera.y + (options and options.y_offset or 0)

    DCEI.SetCameraFocus(camera.x, camera.y, our_duration, use_game_time)

    local ORTHOGRAPHIC = {
        size = 8,
        pitch = 40,
    }
    local camera_size = camera.size or 8
    DCEI.SetCameraMaxOrthographicSize(camera_size)
    DCEI.SetCameraOrthographicSize(camera_size, our_duration, true)
    DCEI.SetCameraPitchSmoothOvertime(ORTHOGRAPHIC.pitch, 0, true)
end

void SetCameraFocusSmoothOvertimeForPlayer(int player, float x, float y, float duration, bool useRealTime = False)

void SetCameraFocusSmoothOvertimeForPlayer(int player, float x, float y, float duration, bool useRealTime = False)

Description


Moves camera focus to the given coordinates for the given player with game time. Only use in multiplayer

Parameters

Example Usage

local player_id = 1
local x, y = 30, 30
local duration = 3
local real_time = true
DCEI.SetEnabledCameraClamp(false)
DCEI.SetCameraFocusSmoothOvertimeForPlayer(player_id, x, y, duration, real_time)

void SetCameraDistance(float targetDistance, float duration = 1, bool useRealTime = False)

void SetCameraDistance(float targetDistance, float duration = 1, bool useRealTime = False)

Description


Sets the camera zoom distance with smooth transition under certain duration of time.

Parameters

Example Usage

local min_distance = DCEI.GetCameraMinDistance()
local max_distance = DCEI.GetCameraMaxDistance()

-- Sets the camera distance to the minimum, and zooms out to the maximum over 3 seconds
DCEI.SetCameraDistance(min_distance, 0, true)
DCEI.SetCameraDistance(max_distance, 3, true)

void SetCameraOrthographicSize(float targetSize, float duration, bool useRealTime = False)

void SetCameraOrthographicSize(float targetSize, float duration, bool useRealTime = False)

Description


Sets the camera's orthographic size. Note that this only works if the camera is set to orthographic mode in under Project Settings -> Map Settings -> Camera -> View Mode.

Parameters

Example Usage

local max_size = 15
local duration = 3
local real_time = true
DCEI.SetCameraMaxOrthographicSize(max_size)
DCEI.SetCameraOrthographicSize(max_size, duration, real_time)

void SetCameraMinOrthographicSize(float targetSize)

void SetCameraMinOrthographicSize(float targetSize)

Description


Sets the camera's min orthographic size. Note that this only works if the camera is set to orthographic mode in under Project Settings -> Map Settings -> Camera -> View Mode.

Parameters

Example Usage

local min_size = 3
local duration = 3
local real_time = true
DCEI.SetCameraMaxOrthographicSize(min_size)
DCEI.SetCameraOrthographicSize(min_size, duration, real_time)

void SetCameraMaxOrthographicSize(float targetSize)

void SetCameraMaxOrthographicSize(float targetSize)

Description


Sets the camera's max orthographic size. Note that this only works if the camera is set to orthographic mode in under Project Settings -> Map Settings -> Camera -> View Mode.

Parameters

Example Usage

local max_size = 15
local duration = 3
local real_time = true
DCEI.SetCameraMaxOrthographicSize(max_size)
DCEI.SetCameraOrthographicSize(max_size, duration, real_time)

float GetCameraOrthographicSize()

float GetCameraOrthographicSize()

Description


Returns the camera's orthographic size.

Example Usage

local max_size = 15
local duration = 0
local real_time = true
DCEI.SetCameraMaxOrthographicSize(max_size)
DCEI.SetCameraOrthographicSize(max_size, duration, real_time)

local size = DCEI.GetCameraOrthographicSize()
DCEI.LogMessage(size)

void SetCameraDistanceSmoothOvertimeForPlayer(int player, float targetDistance, float duration, bool useRealTime = False)

void SetCameraDistanceSmoothOvertimeForPlayer(int player, float targetDistance, float duration, bool useRealTime = False)

Description


Sets the camera zoom distance for the given player.

Parameters

Example Usage

local min_distance = DCEI.GetCameraMinDistance()
local max_distance = DCEI.GetCameraMaxDistance()

-- Sets the camera distance to the minimum, and zooms out to the maximum over 5 seconds
DCEI.SetCameraDistanceSmoothOvertimeForPlayer(1, min_distance, 0, true)
DCEI.SetCameraDistanceSmoothOvertimeForPlayer(1, max_distance, 5, true)

void SetCameraPitchSmoothOvertime(float targetPitchDeg, float duration, bool useRealTime = False)

void SetCameraPitchSmoothOvertime(float targetPitchDeg, float duration, bool useRealTime = False)

Description


Sets the camera pitch.

Parameters

Example Usage

local pitch = 20
local duration = 3
local real_time = false
DCEI.SetCameraPitchSmoothOvertime(pitch, duration, real_time)

void SetCameraPitchSmoothOvertimeForPlayer(int player, float targetPitchDeg, float duration, bool useRealTime = False)

void SetCameraPitchSmoothOvertimeForPlayer(int player, float targetPitchDeg, float duration, bool useRealTime = False)

Description


Sets the camera pitch for the given player.

Parameters

Example Usage

local player = 1
local pitch = 20
local duration = 3
local real_time = false
DCEI.SetCameraPitchSmoothOvertimeForPlayer(player, pitch, duration, real_time)

void SetCameraYawSmoothOvertime(float targetYawDeg, float duration, bool useRealTime = False)

void SetCameraYawSmoothOvertime(float targetYawDeg, float duration, bool useRealTime = False)

Description


Sets the camera yaw to the given angle.

Parameters

Example Usage

local yaw = 360
local duration = 3
local real_time = false
DCEI.SetCameraYawSmoothOvertime(yaw, duration, real_time)

void SetCameraYawSmoothOvertimeForPlayer(int player, float targetYawDeg, float duration, bool useRealTime = False)

void SetCameraYawSmoothOvertimeForPlayer(int player, float targetYawDeg, float duration, bool useRealTime = False)

Description


Sets the camera yaw to the given angle for the given player.

Parameters

Example Usage

local player = 1
local yaw = -720
local duration = 3
local real_time = false
DCEI.SetCameraYawSmoothOvertimeForPlayer(player, yaw, duration, real_time)

float GetCameraPitch()

float GetCameraPitch()

Description


Returns the camera pitch.

Example Usage

local duration = 3
DCEI.SetCameraPitchSmoothOvertime(11, 0, true)
DCEI.SetCameraPitchSmoothOvertime(90, duration, true)
Core.Timer.Real.New({
    duration = duration,
    tick = function()
        local pitch = DCEI.GetCameraPitch()
        DCEI.LogMessage(pitch)
    end,
})

float GetCameraYaw()

float GetCameraYaw()

Description


Returns the camera yaw.

Example Usage

local duration = 3
DCEI.SetCameraYawSmoothOvertime(360, duration, true)
Core.Timer.Real.New({
    duration = duration,
    tick = function()
        local yaw = DCEI.GetCameraYaw()
        DCEI.LogMessage(yaw)
    end,
})

float GetCameraMaxDistance()

float GetCameraMaxDistance()

Description


Returns the camera's maximum zoom distance.

Example Usage

local min_distance = DCEI.GetCameraMinDistance()
local max_distance = DCEI.GetCameraMaxDistance()

-- Sets the camera distance to the minimum, and zooms out to the maximum over 3 seconds
DCEI.SetCameraDistance(min_distance, 0, true)
DCEI.SetCameraDistance(max_distance, 3, true)

float GetCameraMinDistance()

float GetCameraMinDistance()

Description


Returns the camera's minimum zoom distance.

Example Usage

local min_distance = DCEI.GetCameraMinDistance()
local max_distance = DCEI.GetCameraMaxDistance()

-- Sets the camera distance to the minimum, and zooms out to the maximum over 3 seconds
DCEI.SetCameraDistance(min_distance, 0, true)
DCEI.SetCameraDistance(max_distance, 3, true)

Float2 GetCameraCurrentFocalPoint()

Float2 GetCameraCurrentFocalPoint()

Description


Returns the coordinates of the camera's focal point.

Example Usage

local camera_center = DCEI.GetCameraCurrentFocalPoint()
DCEI.LogMessage("x: " .. camera_center.x .. " y: " .. camera_center.y)

Float2 GetCameraBoundsCenterPoint()

Float2 GetCameraBoundsCenterPoint()

Description


Returns the coordinates of the camera bounds' center point.

Example Usage

local camera_bounds_center = DCEI.GetCameraBoundsCenterPoint()
DCEI.LogMessage("x: " .. camera_bounds_center.x .. " y: " .. camera_bounds_center.y)

float GetCameraBoundsHeight()

float GetCameraBoundsHeight()

Description


Return the camera bounds height.

Example Usage

local camera_bounds_height = DCEI.GetCameraBoundsHeight()
DCEI.LogMessage(camera_bounds_height)

float GetCameraBoundsWidth()

float GetCameraBoundsWidth()

Description


Returns the camera bounds width.

Example Usage

local camera_bounds_width = DCEI.GetCameraBoundsWidth()
DCEI.LogMessage(camera_bounds_width)

float GetCameraTargetPointMaxDistance(float x, float y)

float GetCameraTargetPointMaxDistance(float x, float y)

Description


Returns the maximum distance the camera can be from the given coordinates.

Parameters

Example Usage

DCEI.LogMessage(DCEI.GetCameraTargetPointMaxDistance(16, 0))
DCEI.LogMessage(DCEI.GetCameraTargetPointMaxDistance(16, 16))

void BlockCameraInput(bool set)

void BlockCameraInput(bool set)

Description


Toggles camera manipulation from player input.

Parameters

Example Usage

local layout = GMUI.Layout.New({
    parent = DCEI.GetUiRootFrame(),
    name = "Standard/Button/Button",
})
DCEI.SetOnClickCallback(layout.Button, function()
    DCEI.BlockCameraInput(true)
end)

void BlockCameraInputForPlayer(int player, bool set)

void BlockCameraInputForPlayer(int player, bool set)

Description


Toggles camera manipulation from player input for the given player.

Parameters

Example Usage

local layout = GMUI.Layout.New({
    parent = DCEI.GetUiRootFrame(),
    name = "Standard/Button/Button",
})
DCEI.SetOnClickCallback(layout.Button, function()
    DCEI.BlockCameraInputForPlayer(1, true)
end)

void SetCameraVisibleAreaCenter(float x, float y)

void SetCameraVisibleAreaCenter(float x, float y)

Description


Moves the center of the camera visible area. This will move the players' camera(s) accordingly. This does not change the size of the camera's visible area. This can also 'overwrite' the effects of SetEnabledCameraClamp if the new visible area covers previously blocked by camera clamping.

Parameters

Example Usage

local camera_center_x = 0
local camera_center_y = 15
DCEI.SetCameraVisibleAreaCenter(camera_center_x, camera_center_y)

void SetCameraVisibleAreaWidth(float width)

void SetCameraVisibleAreaWidth(float width)

Description


Sets the camera visible area's width. Functions as if bool updateMaxDistance is set to true in the next function. Should be accompanied by SetCameraVisibleAreaLength.

Parameters

Example Usage

local visible_width = 30
local visible_length = 30
DCEI.SetCameraVisibleAreaWidth(visible_width)
DCEI.SetCameraVisibleAreaLength(visible_length)

void SetCameraVisibleAreaLength(float length)

void SetCameraVisibleAreaLength(float length)

Description


Sets the camera visible area's length. Functions as if bool updateMaxDistance is set to true in the next function. Should be accompanied by SetCameraVisibleAreaWidth.

Parameters

Example Usage

local visible_width = 30
local visible_length = 30
DCEI.SetCameraVisibleAreaWidth(visible_width)
DCEI.SetCameraVisibleAreaLength(visible_length)

void SetCameraVisibleAreaWidth(float width, bool updateMaxDistance)

void SetCameraVisibleAreaWidth(float width, bool updateMaxDistance)

Description


Sets the camera visible area's width. Should be accompanied by SetCameraVisibleAreaLength.

Parameters

Example Usage

local visible_width = 10
local visible_length = 10
DCEI.SetCameraVisibleAreaWidth(visible_width, false)
DCEI.SetCameraVisibleAreaLength(visible_length, false)

void SetCameraVisibleAreaLength(float length, bool updateMaxDistance)

void SetCameraVisibleAreaLength(float length, bool updateMaxDistance)

Description


Sets the camera visible area's length. Should be accompanied by SetCameraVisibleAreaWidth().

Parameters

Example Usage

local visible_width = 10
local visible_length = 10
DCEI.SetCameraVisibleAreaWidth(visible_width, false)
DCEI.SetCameraVisibleAreaLength(visible_length, false)

void SetCameraVisibleAreaCenterForPlayer(int player, float x, float y)

void SetCameraVisibleAreaCenterForPlayer(int player, float x, float y)

Description


Moves the center of the camera visible area for the given player. This will move the player's camera(s) accordingly. This does not change the size of the camera's visible area. This can also 'overwrite' the effects of SetEnabledCameraClamp if the new visible area covers previously blocked by camera clamping.

Parameters

Example Usage

local player = 1
local camera_center_x = 0
local camera_center_y = 15
DCEI.SetCameraVisibleAreaCenterForPlayer(player, camera_center_x, camera_center_y)

void SetCameraVisibleAreaWidthForPlayer(int player, float width)

void SetCameraVisibleAreaWidthForPlayer(int player, float width)

Description


Sets the camera visible area's width for the given player. Functions as if bool updateMaxDistance is set to true in the next function. Should be accompanied by SetCameraVisibleAreaLengthForPlayer.

Parameters

Example Usage

DCEI.SetCameraVisibleAreaLengthForPlayer(1, 15)
DCEI.SetCameraVisibleAreaWidthForPlayer(1, 15)

void SetCameraVisibleAreaLengthForPlayer(int player, float length)

void SetCameraVisibleAreaLengthForPlayer(int player, float length)

Description


Sets the camera visible area's length for the given player. Functions as if bool updateMaxDistance is set to true in the next function. Should be accompanied by SetCameraVisibleAreaWidthForPlayer.

Parameters

Example Usage

DCEI.SetCameraVisibleAreaLengthForPlayer(1, 15)
DCEI.SetCameraVisibleAreaWidthForPlayer(1, 15)

void SetCameraVisibleAreaWidthForPlayer(int player, float width, bool updateMaxDistance)

void SetCameraVisibleAreaWidthForPlayer(int player, float width, bool updateMaxDistance)

Description


Sets the camera visible area's width for the given player. Should be accompanied by SetCameraVisibleAreaLength.

Parameters

Example Usage

DCEI.SetCameraVisibleAreaLengthForPlayer(1, 15)
DCEI.SetCameraVisibleAreaWidthForPlayer(1, 15, false)

void SetCameraVisibleAreaLengthForPlayer(int player, float length, bool updateMaxDistance)

void SetCameraVisibleAreaLengthForPlayer(int player, float length, bool updateMaxDistance)

Description


Sets the camera visible area's length for the given player. Should be accompanied by SetCameraVisibleAreaWidthForPlayer.

Parameters

Example Usage

DCEI.SetCameraVisibleAreaWidthForPlayer(1, 15)
DCEI.SetCameraVisibleAreaLengthForPlayer(1, 15, false)

void UsePostProcessingOutline(float width)

void UsePostProcessingOutline(float width)

Description

Parameters

Example Usage