Skip to content

PhantomCamera2D

Inherits: Node2D

PhantomCamera2D, shortened to PCam2D (text) and pcam_2d (code), is used in 2D scenes.

Core Properties

image alt

Priority

Determines which PCam2D should be controlling the Camera2D.

image alt

Follow Mode

Enables the PCam2D to follow specific target(s) using various logics.

image alt

Tween

Determines how the Camera2D should tween to this PCam2D upon becoming active.

Secondary Properties

Active State

Type: bool

Default: false

Returns true if this PCam is the one controlling the scene's Camera.


Getter

bool is_active()

Example
gdscript
pcam.is_active()

Tween on Load

Type: bool

Default: true

By default, the moment a PCam is instantiated into a scene, and has the highest priority, it will perform its tween transition.

This is most obvious if a PCam has a long duration and is attached to a playable character that can be moved the moment a scene is loaded.

Disabling the Tween on Load property will disable this behaviour and skip the tweening entirely when instantiated.

Note: During runtime, properties should be modified and read via their setters & getters respectively.


Setter

void set_tween_on_load(bool value)

Example
gdscript
pcam.set_tween_on_load(false)

Getter

bool is_tween_on_load()

Example
gdscript
pcam.is_tween_on_load()

Inactive Update Mode

Type: int

Default: 0

Determines how often an inactive PCam should update its positional and rotational values. This is meant to reduce the amount of calculations inactive PCams are doing when idling to improve performance. The value is based on the enum type Constants.InactiveUpdateMode.

Inactive Update ModeValue
ALWAYS0
NEVER1

Getter

string get_inactive_update_mode()

Example
gdscript
pcam.get_inactive_update_mode()

Note: This property is only modifiable within the node's inspector panel in the editor.

Zoom

Type: Vector2

Default: Vector2(1,1)

Applies a zoom amount to the PCam2D, which will override the Zoom property of the Camera2D node.

Note: During runtime, properties should be modified and read via their setters & getters respectively.


Setter

void set_zoom(Vector2 value)

Example
gdscript
pcam.set_zoom(Vector2(1.5, 1.5))

Getter

Vector2 get_zoom()

Example
gdscript
pcam.get_zoom()

Frame Preview

Type: bool

Default: true

Enables a preview of what the PCam2D will see in the scene. It works identically to how a Camera2D shows which area will be visible during runtime. Likewise, this too will be affected by the Zoom property and the Viewport Width and Viewport Height defined in the Project Settings.

Note: This property is only accessible within the node's inspector panel in the editor.

Pixel Perfect

Type: bool

Default: false

To support pixel perfect camera movement, this can be toggled to snap Camera2D to always snap to whole pixels.

This should be particularly useful in pixel art projects, where assets should always be aligned to the monitor's pixels to avoid unintended stretching.

Note: During runtime, properties should be modified and read via their setters & getters respectively.


Setter

void set_pixel_perfect(bool value)

Example
gdscript
pcam.set_pixel_perfect(true)

Getter

bool get_pixel_perfect()

Example
gdscript
pcam.get_pixel_perfect()

Draw Limit

Type: bool

Default: false

Shows the Camera2D's built-in limit border. The Camera2D can move around anywhere within it.

Note: This property is only accessible within the node's inspector panel in the editor.

Limit - Left

Type: int

Default: -10000000

Defines the left side of the Camera2D limit. The camera will not be able to move past this point.

Note: During runtime, properties should be modified and read via their setters & getters respectively.


Setter

void set_limit(int side, int value)

Example
gdscript
pcam.set_limit(SIDE_LEFT, 200)

Getter

int get_limit(int side)

Example
gdscript
pcam.get_limit(SIDE_LEFT)

Limit - Top

Type: int

Default: -10000000

Defines the top side of the Camera2D limit. The camera will not be able to move past this point.

Note: During runtime, properties should be modified and read via their setters & getters respectively.


Setter

void set_limit(int side, int value)

Example
gdscript
pcam.set_limit(SIDE_TOP, 200)

Getter

int get_limit(int side)

Example
gdscript
pcam.get_limit(SIDE_TOP)

Limit - Right

Type: int

Default: 10000000

Defines the right side of the Camera2D limit. The camera will not be able to move past this point.

Note: During runtime, properties should be modified and read via their setters & getters respectively.


Setter

void set_limit(int side, int value)

Example
gdscript
pcam.set_limit(SIDE_RIGHT, 200)

Getter

int get_limit(int side)

Example
gdscript
pcam.get_limit(SIDE_RIGHT)

Limit - Bottom

Type: int

Default: 10000000

Defines the bottom side of the Camera2D limit. The camera will not be able to move past this point.

Note: During runtime, properties should be modified and read via their setters & getters respectively.


Setter

void set_limit(int side, int value)

Example
gdscript
pcam.set_limit(SIDE_BOTTOM, 200)

Getter

int get_limit(int side)

Example
gdscript
pcam.get_limit(SIDE_BOTTOM)

Node Limit Target

Type: Node2D

Default: null

Allows for setting either a TileMap or CollisionShape2D node to automatically apply a limit size instead of manually adjusting the Left, Top, Right and Left properties.

TileMap

The Limit will update after the TileSet of the TileMap has changed..

Note: The limit size will only update after closing the TileMap editor bottom panel.

CollisionShape2D

The limit will update in realtime as the Shape2D changes its size.

Note: For performance reasons, resizing the Shape2D during runtime will not change the Limits sides.

Note: During runtime, properties should be modified and read via their setters & getters respectively.


Setter

void set_limit_node(Node2D value)

Example
gdscript
# TileMap node
pcam.set_limit_node(tile_map_node)

# CollisionShape2D node
pcam.set_limit_node(collision_shape_2d_node)

Getter

Node2D get_limit_node()

Example
gdscript
pcam.get_limit_node()

Limit Margin

Type: Vector4i

Default: Vector4i(0,0,0,0)

Applies an offset to the TileMap Limit or Shape2D Limit.

The values goes from Left, Top, Right and Bottom.

Note: During runtime, properties should be modified and read via their setters & getters respectively.


Setter

void set_limit_margin(Vector4i value)

Example
gdscript
pcam.set_limit_margin(Vector4i(200, 200, 200, 200))

Getter

TileMap get_limit_margin()

Example
gdscript
pcam.get_limit_margin()

Limit Smoothed

Type: bool

Default: false

Dampens the Camera2D when it reaches the limit. The smoothness amount is based on the value of Damping property of the Follow Mode.

Note: During runtime, properties should be modified and read via their setters & getters respectively.


Setter

void set_limit_smoothing_enabled(bool value)

Example
gdscript
pcam.set_limit_smoothing_enabled(true)

Getter

bool get_limit_smoothing_enabled()

Example
gdscript
pcam.get_limit_smoothing_enabled()

Signals

Became Active

Signal

became_active

Emitted when the PCam becomes active.

Became Inactive

Signal

became_inactive

Emitted when the PCam becomes inactive.

Tween Started

Signal

tween_started

Emitted when the Camera starts to tween to the PCam.

Is Tweening

Signal

is_tweening

Emitted when the Camera is being tweened.

Tween Interrupted

Signal

tween_interrupted (PhantomCamera pcam)

Emitted when the tween is interrupted due to another PCam becoming active.

The argument is the PCam that interrupted the tween.

Tween Completed

Signal

tween_completed

Emitted when the Camera completes its tween to the PCam.