Skip to content

API Camera

Alexandre 'kidev' Poumaroux edited this page Oct 25, 2026 · 5 revisions

Camera

from proleak import camera

Read the game camera; moving it, and riding a unit in first person, needs the actions capability (local games only).

Classes

Class Description
CameraDict The game camera as get gives it.
Pov A unit view from pov or third_person.

Functions

Returns Function Description
CameraDict get() Where the game camera is and where it looks.
None set(x: float | None = None, y: float | None = None, z: float | None = None, yaw: float | None = None, pitch: float | None = None, fov: float | None = None) Move or turn the camera; omitted values stay as they are.
None focus_unit(unit_id: int) Center the camera on a unit.
None reset() Return the camera to the game's default.
Pov pov(unit: Unit | int, offset: tuple[float, float, float] = (0.0, 0.0, 0.0), pitch: float = 0.0, show_unit: bool = False, look: tuple[float, float] | None = None) Ride unit in first person; returns a Pov.
Pov third_person(unit: Unit | int, distance: float = 6.0, yaw: float | None = None, pitch: float = 25.0, show_unit: bool = True, orbit: bool = True) Follow unit from behind and above; returns a Pov.

Function documentation

get

def get() -> CameraDict

Where the game camera is and where it looks.

set

set(x, y, z, yaw, pitch, fov) -> None
def set(
    x: float | None = None,
    y: float | None = None,
    z: float | None = None,
    yaw: float | None = None,
    pitch: float | None = None,
    fov: float | None = None,
) -> None
Argument Type Default Description
x float | None None The map x to move to.
y float | None None The height to move to.
z float | None None The map z to move to.
yaw float | None None The direction to face, in degrees (Unity's convention: 0 looks along +z).
pitch float | None None How far to look down, in degrees.
fov float | None None The vertical field of view, in degrees.

Move or turn the camera; omitted values stay as they are.

focus_unit

focus_unit(unit_id) -> None
def focus_unit(unit_id: int) -> None
Argument Type Default Description
unit_id int required The unit's id.

Center the camera on a unit.

reset

def reset() -> None

Return the camera to the game's default.

pov

pov(unit, offset, pitch, show_unit, look) -> Pov
def pov(
    unit: Unit | int,
    offset: tuple[float, float, float] = (0.0, 0.0, 0.0),
    pitch: float = 0.0,
    show_unit: bool = False,
    look: tuple[float, float] | None = None,
) -> Pov
Argument Type Default Description
unit Unit | int required The unit, as a Unit or its id.
offset tuple[float, float, float] (0.0, 0.0, 0.0) Moves the camera from the unit's head, as (right, up, forward) in the unit's own frame and in world units.
pitch float 0.0 How far the camera looks down from where the unit faces, in degrees.
show_unit bool False Whether the unit's model stays visible.
look tuple[float, float] | None None Lets the player look around within (horizontal, vertical) degrees, at most 180 each (90 is 45 each way, 0 turns an axis off). None: the view stays fixed.

Ride unit in first person; returns a Pov.

The camera sits at the unit's head (or the top of its model when it has no head point), moved by offset, and looks where the unit faces, pitch degrees down. The unit's health bar is hidden while the view lasts, and ground rings lie flat. A placed fighter hidden during a wave is followed through the unit that fights for it. With look, the player looks around by dragging with the middle mouse button.

One plugin holds the view at a time: calling again (or calling third_person) from the same plugin moves the view to the new unit, from another plugin raises ValueError. The view ends with end, when its unit leaves the game, or when the plugin unloads, and the camera goes back to where it was.

third_person

third_person(unit, distance, yaw, pitch, show_unit, orbit) -> Pov
def third_person(
    unit: Unit | int,
    distance: float = 6.0,
    yaw: float | None = None,
    pitch: float = 25.0,
    show_unit: bool = True,
    orbit: bool = True,
) -> Pov
Argument Type Default Description
unit Unit | int required The unit, as a Unit or its id.
distance float 6.0 How far the camera is from the unit's head, in world units.
yaw float | None None The direction the camera faces, in degrees (Unity's convention: 0 looks along +z). None: behind the unit.
pitch float 25.0 How far the camera looks down, in degrees.
show_unit bool True Whether the unit's model stays visible.
orbit bool True Whether the player can turn the camera around the unit (middle mouse button) and move it closer or further (wheel).

Follow unit from behind and above; returns a Pov.

The camera looks at the unit's head (or the top of its model). With orbit, read the view's yaw, pitch and distance to keep where the player left it. The view is held and ends as pov describes.

CameraDict class

The game camera as get gives it.

A plain dict with these keys.

Type Key Description
float x Map x position.
float y Height.
float z Map z position.
float yaw The direction it faces, in degrees (Unity's convention: 0 looks along +z).
float pitch Degrees it looks down.
float fov Its vertical field of view, in degrees.

Key documentation

x

x: float

Map x position.

y

y: float

Height.

z

z: float

Map z position.

yaw

yaw: float

The direction it faces, in degrees (Unity's convention: 0 looks along +z).

pitch

pitch: float

Degrees it looks down.

fov

fov: float

Its vertical field of view, in degrees.

Pov class

A unit view from pov or third_person. Setting a property takes effect at the next frame.

Type Property Description
str mode read-only "first" or "third".
tuple[float, float, float] offset read-only First person: (right, up, forward) from the anchor, in the unit's frame.
tuple[float, float] | None look read-only First person: (horizontal, vertical) look ranges in degrees, or None when off.
float pitch read-only Degrees the camera looks down (negative: up).
float distance read-only Third person: how far the camera is from the unit.
float | None yaw read-only Third person: the direction the camera faces, or None until it is first placed.
bool show_unit read-only Whether the unit's model stays visible.
bool alive read-only False once the view has ended.
int unit read-only The id of the unit the camera rides now (the wave fighter, during a wave).
str type read-only The unit type of the unit the view was started on.
str anchor read-only "head" or "top": where the view is measured from.
Returns Method Description
None end() End the view and put the camera back; does nothing once it has ended.

Property documentation

mode

mode: str  # read-only

"first" or "third".

offset

offset: tuple[float, float, float]  # read-only

First person: (right, up, forward) from the anchor, in the unit's frame.

look

look: tuple[float, float] | None  # read-only

First person: (horizontal, vertical) look ranges in degrees, or None when off.

pitch

pitch: float  # read-only

Degrees the camera looks down (negative: up).

distance

distance: float  # read-only

Third person: how far the camera is from the unit.

yaw

yaw: float | None  # read-only

Third person: the direction the camera faces, or None until it is first placed.

show_unit

show_unit: bool  # read-only

Whether the unit's model stays visible.

alive

alive: bool  # read-only

False once the view has ended.

unit

unit: int  # read-only

The id of the unit the camera rides now (the wave fighter, during a wave).

type

type: str  # read-only

The unit type of the unit the view was started on.

anchor

anchor: str  # read-only

"head" or "top": where the view is measured from.

Method documentation

end

def end() -> None

End the view and put the camera back; does nothing once it has ended.


Previous: Background tasks | Next: Chat

Clone this wiki locally