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.


Setter ​

void set_lookahead(bool value)

Example
gdscript
pcam.set_lookahead(true)
Example
gdscript
pcam.set_follow_lookahead(true)

Getter ​

bool get_lookahead()

bool get_follow_lookahead()

Example
gdscript
pcam.get_lookahead()
Example
gdscript
pcam.get_follow_lookahead()

lookahead_time ​

Type: Vector2

Default: Vector2(0.5, 0.5)

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

Each axis has its own prediction time in seconds.

A value of 0 can be set to disable lookahead for the corresponding axis.


Setter ​

void set_lookahead_time(Vector2 value)

Example
gdscript
pcam.set_lookahead_time(Vector2(0.3, 0.3))
Example
gdscript
pcam.set_follow_lookahead_time(Vector3(1, 1, 1))

Getter ​

bool get_lookahead_time()

bool get_follow_lookahead_time()

Example
gdscript
pcam.get_lookahead_time()
Example
gdscript
pcam.get_follow_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 moves

Lower value = faster.

Higher value = slower.


Setter ​

void set_lookahead_acceleration(float value)

Example
gdscript
pcam.set_lookahead_acceleration(0.8)
Example
gdscript
pcam.set_follow_lookahead_acceleration(0.6)

Getter ​

bool get_lookahead_acceleration()

bool get_follow_lookahead_acceleration()

Example
gdscript
pcam.get_lookahead_acceleration()
Example
gdscript
pcam.get_follow_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 when it stops moving.

Lower value = faster.

Higher value = slower.


Setter ​

void set_lookahead_deceleration(float value)

Example
gdscript
pcam.set_lookahead_deceleration(0.4)
Example
gdscript
pcam.set_follow_lookahead_deceleration(0.6)

Getter ​

bool get_lookahead_deceleration()

bool get_follow_lookahead_deceleration()

Example
gdscript
pcam.get_lookahead_deceleration()
Example
gdscript
pcam.get_follow_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 trakced 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.


Setter ​

void set_lookahead_max(bool value)

Example
gdscript
pcam.set_lookahead_max(true)
Example
gdscript
pcam.set_follow_lookahead_max(true)

Getter ​

bool get_lookahead_max()

bool get_follow_lookahead_max()

Example
gdscript
pcam.get_lookahead_max()
Example
gdscript
pcam.get_follow_lookahead_max()

lookahead_max_value ​

Type: Vector2

Default: Vector2(200, 200)

The maximum lookahead velocity in pixels per second.

The follow target's tracked velocity will be clamped within these bounds on each axis before applying lookahead time.


Setter ​

void set_lookahead_max_value(Vector2 value)

Example
gdscript
pcam.set_lookahead_max_value(Vector2(600, 600))
Example
gdscript
pcam.set_lookahead_max_value(Vector3(10, 10, 10))

Getter ​

Vector2 get_lookahead_max_value()

Vector3 get_lookahead_max_value()

Example
gdscript
pcam.get_lookahead_max_value()
Example
gdscript
pcam.get_lookahead_max_value()

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