Group Follow
Allows for multiple nodes to be followed and affect the PCam
's positional behaviour. It works by setting a Rect2
(2D) or AABB
(3D) bounding box around the targets where the PCam
will track the centre of it.
An Auto Zoom (2D) and Auto Distance (3D) parameter can be applied to dynamically make the PCam
readjust itself to keep multiple targets within view if they start to spread out.
This mode can be useful for single stage experiences that relies on having multiple targets in view at all times.
Video Examples
Properties
follow_targets
Type: Array[Node2D]
Default: null
Defines the nodes that the PCam
should be following.
Setter
void
set_follow_targets(Array[Node2D]
target_nodes)
void
append_follow_targets(Node2D
target_node)
void
append_follow_targets_array(Array[Node2D]
target_nodes)
void
erase_follow_targets(Node2D
target_node)
Example
# Assigns a new array of nodes to the Follow Group
pcam.set_follow_targets(node_collection)
# Appends one node to the Follow Group
pcam.append_follow_targets(player_node)
# Appends an array of nodes to the Follow Group
pcam.append_follow_targets_array(node_array)
# Removes a node from the Follow Group
pcam.erase_follow_targets(another_node)
follow_damping
Type: bool
Default: false
Applies a damping effect on the Camera
's movement. Leading to heavier / slower camera movement as the targeted node moves around.
This is useful to avoid sharp and rapid camera movement.
damping_value
Type: Vector2
Default: Vector2(0.1, 0.1)
Defines the damping amount. The ideal range should be somewhere between 0-1, likely somewhere around 0.1-0.25.
The damping amount is specified in the individual axis. X and Y for 2D and X, Y and Z for 3D scenes. To have the damping be consistent in all directions, simply supply the same value in all slots.
Lower value = faster / sharper camera movement.
Higher value = slower / heavier camera movement.
Setter
void
set_follow_damping_value(Vector2
damping_value)
Example
pcam.set_follow_damping_value(Vector2(0.2, 0.2))
auto_zoom
Type: bool
Default: false
Enables the PCam2D
to dynamically zoom in and out based on the targets' distances between each other.
Once enabled, the PCam
will stay as zoomed in as possible, limited by the Maximum Zoom
and start zooming out as the targets move further apart, limited by the Minimum Zoom
.
Note
Enabling this property hides and disables the Zoom
property as this will override it.
This property is for PCam2D
only.
The PCam3D
alternative to this can be found in the auto_follow_distance section.
auto_zoom_min
Type: float
Default: 1
Sets the minimum zoom amount, in other words how far away the Camera2D
can be from the scene.
This only works when auto_zoom
is enabled.
This property is for PCam2D
only.
The PCam3D
alternative to this can be found in the auto_follow_distance_max section.
auto_zoom_max
Type: float
Default: 5
Sets the maximum zoom amount, in other words how close the Camera2D
can move towards the scene.
This only works when auto_zoom
is enabled.
This property is for PCam2D
only.
The PCam3D
alternative to this can be found in the auto_follow_distance_min section.
auto_zoom_margin
Type: Vector4
Default: Vector4(0,0,0,0)
Determines how close to the edges the targets are allowed to be.
This is useful to avoid targets being cut off at the edges of the screen.
The Vector4
parameter order goes: Left - Top - Right - Bottom.
This property is for PCam2D
only.
Setter
void
set_auto_zoom_margin (Vector4
zoom_margin)
Example
pcam.set_auto_zoom_margin(Vector4(10, 30, 10, 40))
follow_distance
Type: float
Default: 1
Sets a distance offset from the centre of the target. The distance is applied to the PCam
's local z axis.
This property is for PCam3D
only.
The PCam2D
alternative to this can be found in the zoom section.
auto_follow_distance
Type: bool
Default: false
Enables the PCam
to automatically move further away based on the targets' distances between each other.
It looks at the longest axis between the different targets and interpolates the distance length between the Minimum Distance
and Maximum Distance
properties below.
Note
Enabling this property hides and disables the Distance
property as this will override it.
This property is for PCam3D
only.
The PCam2D
alternative to this can be found in the auto_zoom section.
Setter
void
set_auto_follow_distance(bool
enable)
Example
pcam.set_auto_follow_distance(true)
auto_follow_distance_min
Type: float
Default: 1
Sets the minimum distance between the Camera
and centre of AABB
.
Note
This distance will only ever be reached when all the targets are in the exact same Vector3
coordinate, which will very unlikely happen, so adjust the value here accordingly.
This property is for PCam3D
only.
The PCam2D
alternative to this can be found in the auto_zoom_max section.
Setter
void
set_auto_follow_distance_min(float
min_distance)
Example
pcam.set_auto_follow_distance_min(4.2)
auto_follow_distance_max
Type: float
Default: 5
Sets the maximum distance between the Camera
and centre of AABB
.
This property is for PCam3D
only.
The PCam2D
alternative to this can be found in the auto_zoom_min section.
Setter
void
set_auto_follow_distance_max(float
max_distance)
Example
pcam.set_auto_follow_distance_max(4.2)
auto_follow_distance_divisor
Type: float
Default: 10
Determines how fast the auto_follow_distance
moves between the maximum and minimum distance. The higher the value, the sooner the maximum distance is reached.
This value should be based on the sizes of the auto_follow_distance_min
and auto_follow_distance_max
.
E.g. if the value between the auto_follow_distance_min
and auto_follow_distance_max
is small, consider keeping the number low and vice versa.
This property is for PCam3D
only.
Setter
void
set_auto_follow_distance_divisor(float
division)
Example
pcam.set_auto_follow_distance_divisor(4.2)
Getter
float
get_auto_follow_distance_divisor()
Example
pcam.get_auto_follow_distance_divisor()