Skip to content

PhantomCameraHost

Inherits: Node

Shortened to PCamHost (text) and pcam_host (code) manages a scene's PCam nodes and is what ultimately supplies the logic to the Camera. It decides which PCam the Camera should be attached to and, consequently, its logic.

Multiple PhantomCameraHosts

Each scene can contain an unlimited amount of PCamHosts and Camera2D/3D nodes, where multiple PCamHosts can belong to the same PCam at the same time; leading to each camera having the same Follow or Look At behavior.

Tip

In the vast majority of cases, having multiple PCamHosts is not necessary. Using more than one is mainly for use-cases where multiple cameras need to render different things at the same time, such as for splitscreen co-op.

Once more than one PCamHosts is in a given scene, the Viewfinder will display a collapsible list of all the PCamHosts instances in the current scene.
See the Viewfinder page for more details.

Properties

host_layers

Type: int

Default: 1

Determines which PCam2D / PCam3D nodes this PCamHost should recognize.

At least one corresponding layer needs to be set on the PCam node for the PCamHost to recognize it.

Note: The layer value uses a bitmask.

Tip

A helper function also exists called set_host_layers_value(), where you can supply a specific layer number and then enable / disable it (see setter example below). Use this if you prefer not having to supply bitmask values.


Setter

void set_host_layers(int value)

void set_host_layers_value(int layer, bool enabled)

Example
gdscript
## Bitmask assignment
pcam_host.set_host_layers(10) # Enables the 2nd and 4th layer using a bitmask value

## Specific layer change
pcam_host.set_host_layers_value(4, true) # Enables the 4th layer

Getter

int get_host_layers()

Example
gdscript
pcam_host.get_host_layers() # Returns the layer value as a bitmask

interpolation_mode

Type: int

Default: 0

Determines whether the PhantomCamera2D / PhantomCamera3D nodes this PhantomCameraHost controls should use physics interpolation or not.

InterpolationModeValueDescription
AUTO0Automatically detects the physics interpolation based on the active PCam
IDLE1Forces the camera to only update in the idle / process ticks
PHYSICS2Forces the camera to only update in the physics / physics process ticks
MANUAL3Only updates when the process function is called from the PCamHost node.

Setter

void set_interpolation_mode(int value)

Example
gdscript
pcam_host.set_interpolation_mode(InterpolationMode.IDLE)

Getter

int get_interpolation_mode()

Example
gdscript
pcam_host.get_interpolation_mode() # Returns the current interpolation mode

Methods

Node get_active_pcam

Returns the currently active PCam2D / PCam3D for this PCamHost node.

Example
gdscript
pcam_host.get_active_pcam()

void process (float delta)

Manually updates the process for this PCamHost.

Important

This function should only be needed if InterpolationMode is set to InterpolationMode.MANUAL.

Example
gdscript
pcam_host.process(delta)

Signals

pcam_became_active (pcam: Node)

Emitted when a new PCam becomes active and assigned to this PCamHost.

The argument is the PCam that became active.

pcam_became_inactive (pcam: Node)

Emitted when the currently active PCam goes from being active to inactive.

The argument is the PCam that became inactive.

Made with ♥ in Vitepress