Skip to content

Follow Overview

Determines the positional logic for a given PCam.

The different modes have different functionalities and purposes, so choosing the correct one depends on what each PCam is meant to do.

Core Modes

image alt

Glued

Sticks to its target.

image alt

Simple

Follows its target with an optional offset.

image alt

Group

Follows multiple targets with the option to dynamically reframe itself as targets move further apart.

image alt

Path

Follows a target while being positionally confined to a Path node.

image alt

Framed

Applies a dead zone to the frame and only follows its target when it tries to leave it.

image alt

Third Person

Applies a SpringArm3D node to its target and allows for rotating around it.

Properties

follow_mode

Type: int

Default: 0

Defines the current Follow Mode of the PCam based on FOLLOW_MODE enum.

Follow ModeValue
NONE0
GLUED1
SIMPLE2
GROUP3
PATH4
FRAMED5
THIRD_PERSON6

Only Third Person Follow is exclusive to 3D scenes.

Important

This property should not be changed during runtime, as such the setter for this has purposely been excluded.

To use another follow_mode at runtime, switch to a separate PCam with the specific follow_mode applied.


Getter

int get_follow_mode()

Example
gdscript
pcam.get_follow_mode()

follow_axis_lock

Type: int

Default: 0

Prevents camera movement in one or multiple world axes.

Locking a PCam does not change its position nor take its Follow Target's transform values into account.

Note

This only applies once the PCam has a valid Follow Target.

2D

FollowLockAxisValue
NONE0
X1
Y2
XY3

3D

FollowLockAxisValue
NONE0
X1
Y2
Z3
XY4
XZ5
YZ6
XYZ7

Setter

void set_follow_lock_axis(int value)

Example
gdscript
pcam.set_follow_axis_lock(2)

Getter

int get_follow_lock_axis()

Example
gdscript
pcam.get_follow_axis_lock()

lookahead

Type: bool

Default: false

Enables velocity-based lookahead.
As the follow target moves the camera will move further ahead based on its velocity. The faster the follow target moves, the further ahead the camera will move.

Phantom Camera 2D

This property is for PCam2D only.


Setter

void set_lookahead(bool enable)

Example
gdscript
pcam.set_lookahead(true)

Getter

bool get_lookahead()

Example
gdscript
pcam.get_lookahead()

lookahead_time

Type: Vector2

Default: Vector2(0.5, 0.5)

The amount of seconds to look ahead of the [param follow target]'s position per axis based on the [param follow target]'s velocity.

Each axis has its own prediction time in seconds. A value of 0 can be set either to disable lookahead for the corresponding axis.

Phantom Camera 2D

This property is for PCam2D only.


Setter

void set_lookahead_time(Vector2 value)

Example
gdscript
pcam.set_lookahead_time(Vector2(0.4, 0.2))

Getter

Vector2 get_lookahead_time()

Example
gdscript
pcam.get_lookahead_time()

lookahead_acceleration

Type: float

Default: 0.2

Determines the damping speed of how fast the camera should reach the lookahead_time target once the follow target has a positional velocity.
Lower value = faster.
Higher value = slower.

Phantom Camera 2D

This property is for PCam2D only.


Setter

void set_lookahead_acceleration(float value)

Example
gdscript
pcam.set_lookahead_acceleration(0.6)

Getter

float get_lookahead_acceleration()

Example
gdscript
pcam.get_lookahead_acceleration()

lookahead_deceleration

Type: float

Default: 0.2

Determines the damping speed of how fast the camera should decelerate back to the follow target's position once it has no positional velocity.
Lower value = faster.
Higher value = slower.

Phantom Camera 2D

This property is for PCam2D only.


Setter

void set_lookahead_deceleration(float value)

Example
gdscript
pcam.set_lookahead_deceleration(0.6)

Getter

float get_lookahead_deceleration()

Example
gdscript
pcam.get_lookahead_deceleration()

lookahead_max

Type: bool

Default: false

Enables a maximum velocity limit in pixels per second for the follow_lookahead effect.

If true, the follow target's velocity will be clamped to the follow_lookahead_max_value before calculating lookahead.
In other words, no matter how fast the target's actual velocity is, the lookahead will only follow up to the speed defined here.

Phantom Camera 2D

This property is for PCam2D only.


Setter

void set_lookahead_max(float value)

Example
gdscript
pcam.set_lookahead_max(Vector2(500, 500))

Getter

float get_lookahead_deceleration()

Example
gdscript
pcam.get_lookahead_deceleration()

lookahead_max_value

Type: Vector2

Default: Vector2(200, 200)

The maximum lookahead velocity in pixels per second. The follow target's velocity will be clamped within these bounds on each axis before applying lookahead time.

Phantom Camera 2D

This property is for PCam2D only.


Setter

void set_lookahead_max(float value)

Example
gdscript
pcam.set_lookahead_max(Vector2(500, 500))

Getter

float get_lookahead_deceleration()

Example
gdscript
pcam.get_lookahead_deceleration()

Methods

bool is_following

Returns true if the PCam follow_mode is not set to NONE and has a valid follow_target.

Example
gdscript
pcam.is_following()

Made with ♥ in Vitepress