Skip to content

API Camera

Alexandre 'kidev' Poumaroux edited this page Oct 21, 2026 · 4 revisions

Camera

Import 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
CameraDict The game camera as get gives it.
Pov A unit view from pov or third_person.

Functions

Returns Function
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 (an id or a 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

get() -> CameraDict

Where the game camera is and where it looks.

set

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

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

focus_unit

focus_unit(unit_id: int) -> None

Center the camera on a unit.

reset

reset() -> None

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) -> Pov

Ride unit (an id or a 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, three numbers (right, up, forward) in the unit's own frame and in world units, and looks where the unit faces, pitch degrees down. With show_unit=False the unit's model is hidden while the view lasts; its health bar is hidden in any case, and ground rings lie flat. A placed fighter hidden during a wave is followed through the unit that fights for it. look=(horizontal, vertical) lets the player look around by dragging with the middle mouse button, inside those angles in degrees (90 is 45 each way, 0 turns an axis off, at most 180).

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: Unit | int, distance: float = 6.0, yaw: float | None = None, pitch: float = 25.0, show_unit: bool = True, orbit: bool = True) -> Pov

Follow unit from behind and above; returns a Pov.

The camera looks at the unit's head (or the top of its model) from distance world units away, facing yaw degrees (Unity's convention: 0 looks along +z; None starts behind the unit) and looking pitch degrees down. With orbit=True the player turns the camera around the unit by dragging with the middle mouse button and moves it closer or further with the wheel; read yaw, pitch and distance to keep where they 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
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
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
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

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