PhantomCamera2D
Inherits: Node2D
PhantomCamera2D, shortened to PCam2D (text) and pcam_2d (code), is used in 2D scenes.
Core Properties
Follow Mode
Enables the PCam2D to follow specific target(s) using various logics.
Secondary Properties
Active State
Type: bool
Default: false
Returns true if this PCam is the one controlling the scene's Camera.
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.
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 Mode | Value |
|---|---|
| ALWAYS | 0 |
| NEVER | 1 |
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.
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.
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.
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.
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.
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.
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
# TileMap node
pcam.set_limit_node(tile_map_node)
# CollisionShape2D node
pcam.set_limit_node(collision_shape_2d_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
pcam.set_limit_margin(Vector4i(200, 200, 200, 200))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
pcam.set_limit_smoothing_enabled(true)Signals
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.