Skip to content
Third Person Icon

Third Person Follow (3D)

As the name implies, this mode is meant to be used for third person camera experiences. It works by applying a SpringArm3D where the properties, such as Collison Mask, Spring Length and Margin, can be controlled from the PCam3D.

To adjust the orbit rotation around the target, use one of the following setter methods:

Video Example

Properties

follow_target

Type: Node3D

Default: null

Determines which Node should be followed. The PCam3D will follow the position of the Follow Target based on the Follow Mode and its parameters.


Setter

void set_follow_target(Node3D target_node)

Example
gdscript
pcam.set_follow_target(player_node)

Getter

Node3D get_follow_target()

Example
gdscript
pcam.get_follow_target()

follow_offset

Type: Vector3

Default: Vector3(0,0,0)

Offsets the follow target's position.


Setter

void set_follow_offset(Vector3 offset)

Example
gdscript
pcam.set_follow_offset(Vector3(1, 1, 1))

Getter

Vector3 get_follow_offset()

Example
gdscript
pcam.get_follow_offset()

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.


Setter

void set_follow_damping(bool enable)

Example
gdscript
pcam.set_follow_damping(true)

Getter

bool get_follow_damping()

Example
gdscript
pcam.get_follow_damping()

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
gdscript
pcam.set_follow_damping_value(Vector2(0.2, 0.2))
Example
gdscript
pcam.set_follow_damping_value(Vector3(0.2, 0.2, 0.2))

Getter

Vector2 get_follow_damping_value()

Vector3 get_follow_damping_value()

Example
gdscript
pcam.get_follow_damping_value()
Example
gdscript
pcam.get_follow_damping_value()

spring_length

Type: float

Default: 1.0

Defines the SpringArm3D node's spring length. This is the equivalent of defining the distance property in other FollowModes.


Setter

void set_spring_length(float length)

Example
gdscript
pcam.set_spring_length(4.2)

Getter

float get_spring_length()

Example
gdscript
pcam.get_spring_length()

collision_mask

Type: int

Default: 1

Defines the SpringArm3D node's Collision Mask.

A simplified helper setter method can be found in the example code below.


Setter

void set_collision_mask(int mask_int)

void set_collision_mask_value(int mask_layer, bool enable)

Example
gdscript
# Use this to assign a specific layer value.
# Fairly complex to use, so the function below this is recommended.
pcam.set_collision_mask(4)

# Use this helper method to enable or disable a specific layer.
pcam.set_collision_mask_value(2, true)

Getter

float get_collision_mask()

Example
gdscript
pcam.get_collision_mask()

shape

Type: Shape3D

Default: null

Defines the SpringArm3D node's Shape3D.


Setter

void set_shape(Shape3D shape)

Example
gdscript
pcam.set_shape(shape)

Getter

float get_shape()

Example
gdscript
pcam.get_shape()

margin

Type: float

Default: 0.01

Defines the SpringArm3D node's Margin.


Setter

void set_margin(float margin)

Example
gdscript
pcam.set_margin(0.42)

Getter

float get_margin()

Example
gdscript
pcam.get_margin()

Methods

Rotation (Quaternion)

Type: Quaternion

Default: n/a

Defines the quaternion value of the Third Person SpringArm3D node.


Setter

void set_third_person_quaternion(Quaternion spring_arm_rotation_deg)

Example
gdscript
pcam.set_third_person_quaternion(quaternion)

Getter

Quaternion get_third_person_quaternion()

Example
gdscript
pcam.get_third_person_quaternion()

Rotation (Radians)

Type: Vector3

Default: Vector3(0,0,0)

Defines the rotation (in radians) value of the Third Person SpringArm3D node.


Setter

void set_third_person_rotation(Vector3 spring_arm_rotation)

Example
gdscript
pcam.set_third_person_rotation(Vector3(-30, 0, 0))

Getter

Vector3 get_third_person_rotation()

Example
gdscript
pcam.get_third_person_rotation()

Rotation (Degrees)

Type: Vector3

Default: Vector3(0,0,0)

Defines the rotation (in degrees) value of the Third Person SpringArm3D node.


Setter

void set_third_person_rotation_degrees(Vector3 spring_arm_rotation_deg)

Example
gdscript
pcam.set_third_person_rotation_degrees(Vector3(-30, 0, 0))

Getter

Vector3 get_third_person_rotation_degrees()

Example
gdscript
pcam.get_third_person_rotation_degrees()

Example Setup

gdscript
var mouse_sensitivity: float = 0.05

var min_yaw: float = 0
var max_yaw: float = 360

var min_pitch: float = -89.9
var max_pitch: float = 50

func _unhandled_input(event) -> void:
  # Trigger whenever the mouse moves.
  if event is InputEventMouseMotion:
    var pcam_rotation_degrees: Vector3

    # Assigns the current 3D rotation of the SpringArm3D node - to start off where it is in the editor.
    pcam_rotation_degrees = pcam.get_third_person_rotation_degrees()

    # Change the X rotation.
    pcam_rotation_degrees.x -= event.relative.y * mouse_sensitivity
		
    # Clamp the rotation in the X axis so it can go over or under the target.
    pcam_rotation_degrees.x = clampf(pcam_rotation_degrees.x, min_pitch, max_pitch)

    # Change the Y rotation value.
    pcam_rotation_degrees.y -= event.relative.x * mouse_sensitivity
		
    # Sets the rotation to fully loop around its target, but without going below or exceeding 0 and 360 degrees respectively.
    pcam_rotation_degrees.y = wrapf(pcam_rotation_degrees.y, min_yaw, max_yaw)
		
    # Change the SpringArm3D node's rotation and rotate around its target.
    pcam.set_third_person_rotation_degrees(pcam_rotation_degrees)