Skip to content

ThirdPersonCameraLogic ​

Inherits: CameraLogic < Resource

Unified third-person camera with configurable orbit and follow behavior. Input arrives from the InputManager (uses_input_manager() == true); this logic never polls mouse buttons and never touches Input.mouse_mode.

Description ​

Authority: the CONTROLLER owns the body's facing, this camera owns yaw/pitch of the view. The camera yaw is absolute (it does not ride the body), which is what makes both control schemes work. The scheme is chosen by the controller (ControllerLogic.get_movement_basis):

CHARACTER basis (W = the way the character faces):

  • Right-drag (CHARACTER_LOOK): the controller turns the body; the camera applies pitch only and

locks its yaw to the body's facing. The camera never writes the body's rotation.

  • Left-drag (FREE_LOOK): manual orbit that leaves the body alone (optional, disables the

follow until the player moves)

  • Auto-follow: the camera swings back behind the body while the player walks (optional)

CAMERA basis (W = the way the camera faces):

  • Right-drag and left-drag both orbit the camera (FREE_LOOK); the body turns to face the way it

moves, so the camera must NOT follow the body while walking (it never does in this basis)

Look speed: the player's mouse sensitivity setting x look_sensitivity_scale (see CameraLogic)

Properties ​

floatvertical_angle_min-80.0
floatvertical_angle_max80.0
boolallow_manual_orbittrue
boolenable_auto_follow_on_movementtrue
floatfollow_direction_speed5.0
boolcollision_enabledtrue
CollisionLayerUtility.CollisionLayercollision_layerCollisionLayerUtility.CollisionLayer.CAMERA_DETECTION
floatcamera_radius0.3
floatcollision_smoothing10.0

Variables ​

Node3Dtarget
floathorizontal_angle0.0
floatvertical_angle0.0
boolis_character_look_activefalse
boolis_free_look_activefalse
floattarget_camera_z3.5
boolis_follow_enabledtrue
boolis_aligning_to_bodyfalse
RayCast3Dcamera_raycastnull

Methods ​

voidsetup( cm: CameraController )
voidprocess_camera( delta: float )
booluses_input_manager()
Array[LookBinding]get_look_bindings()
voidon_look_state( kind: LookBinding.Kind, active: bool )
voidhandle_look( kind: LookBinding.Kind, delta_rad: Vector2 )
voidhandle_zoom( steps: int )
voidset_target( new_target: Variant, use_pan: bool = true )
voidcleanup()
floatget_view_yaw()
Stringget_type_display_name()
Array[String]validate()
boolis_camera_being_controlled()

Constants ​

  • float EVENT_PAN_SECONDS = 1.0 - Seconds a pan to an event position (set_target with a Vector3) takes

Property descriptions ​

Third Person Rotation

float vertical_angle_min = -80.0 ​

Minimum vertical angle

float vertical_angle_max = 80.0 ​

Maximum vertical angle

Orbit Behavior

bool allow_manual_orbit = true ​

Allow left mouse drag for manual camera orbit (drag distance before it starts: GameplayConfig.look_drag_threshold)

bool enable_auto_follow_on_movement = true ​

Enable auto-follow when player moves (character-relative movement only)

Follow Behavior

float follow_direction_speed = 5.0 ​

Speed at which camera follows player direction

Collision Detection

bool collision_enabled = true ​

Enable collision detection

CollisionLayerUtility.CollisionLayer collision_layer = CollisionLayerUtility.CollisionLayer.CAMERA_DETECTION ​

Collision layer to check

float camera_radius = 0.3 ​

Buffer distance from collision

float collision_smoothing = 10.0 ​

Collision smoothing speed

Variable descriptions ​

Node3D target ​

Runtime state

float horizontal_angle = 0.0 ​

Camera yaw in degrees (absolute, same convention as Node3D.rotation_degrees.y)

float vertical_angle = 0.0 ​

Camera pitch in degrees (+ = looking up)

bool is_character_look_active = false ​

RMB mouse-look is active (set from InputManager via on_look_state)

bool is_free_look_active = false ​

A free-look orbit is active (set from InputManager via on_look_state)

float target_camera_z = 3.5 ​

How far behind the target the camera wants to be (changed by the zoom).

bool is_follow_enabled = true ​

True while the camera follows the target.

bool is_aligning_to_body = false ​

True from mouse-look start until the camera has eased back to the player's facing (after a free orbit)

RayCast3D camera_raycast = null ​

The ray that pulls the camera closer when something is in the way.

Method descriptions ​

void setup( cm: CameraController ) ​

Sets the logic up when it becomes the one in use.

void process_camera( delta: float ) ​

Moves the camera one frame.

bool uses_input_manager() ​

Does the logic get its look input from the input manager?

Array[LookBinding] get_look_bindings() ​

The mouse buttons that turn the view or the character for this logic.

void on_look_state( kind: LookBinding.Kind, active: bool ) ​

Called when a look button is pressed or released.

void handle_look( kind: LookBinding.Kind, delta_rad: Vector2 ) ​

Turns the view or the character by the mouse movement.

void handle_zoom( steps: int ) ​

Zooms by the steps of the mouse wheel (positive steps zoom in).

void set_target( new_target: Variant, use_pan: bool = true ) ​

Sets what the camera follows. With pan on, it glides there.

void cleanup() ​

Lets go of what the logic holds when it is replaced.

float get_view_yaw() ​

The camera's own yaw (not derived from the node, so it is exact right after input)

String get_type_display_name() ​

The name of the logic in the editor.

Array[String] validate() ​

Checks the settings. Gives the problems found (empty when it is fine).

bool is_camera_being_controlled() ​

Is the player turning the camera now?