Skip to content

CameraLogic ​

Inherits: Resource

Inherited by: ThirdPersonCameraLogic, TopdownFocusedLogic, TopdownFreeLogic

Base camera logic resource - both configuration and runtime behavior Save instances to res://src/data/controller_logic/camera/

Description ​

Child classes:

  1. Add exported properties for configuration

  2. Override setup/process_camera/handle_input for behavior

  3. Override get_type_display_name() for editor display

Properties ​

Stringpreset_name"Unnamed Camera"
boolzoom_with_window_opentrue
Stringdescription""
Vector3initial_socket_positionVector3.ZERO
Vector3initial_socket_rotation_degreesVector3(-20.0, 0.0, 0.0)
Vector3initial_camera_positionVector3(0, 1.5, 3.5)
Vector3initial_camera_rotation_degreesVector3(-7.0, 0.0, 0.0)
floatfield_of_view75.0
floatnear_clip0.05
floatfar_clip500.0
boolshake_on_landingfalse
floatlanding_min_height3.0
floatlanding_shake_amount0.3
boolshake_on_big_hitfalse
floatbig_hit_min_percent15.0
floatbig_hit_shake_amount0.4
floatzoom_min3.0
floatzoom_max10.0
floatzoom_speed2.0
floatzoom_smoothing0.1
floatfollow_speed5.0
floatfollow_smoothing0.95
floatfollow_distance_threshold0.1
boolenable_target_locktrue
floattarget_lock_rotation_speed8.0
floattarget_lock_screen_offset0.1
floatlook_sensitivity_scale1.0

Variables ​

GameHost.SystemHubsystem_hub
CameraControllercamera_manager
boolis_locked_to_targetfalse
Variantlocked_targetnull

Methods ​

voidinitialize( p_system_hub: GameHost.SystemHub )
voidbind_lock_source( player: Variant )
voidunbind_lock_source()
voidapply_to_camera_manager( camera_manager: CameraController )
voidsetup( camera_manager: CameraController )
voidprocess_camera( delta: float )
voidhandle_input( event: InputEvent )
booluses_input_manager()
Array[LookBinding]get_look_bindings()
voidhandle_look( kind: LookBinding.Kind, delta_rad: Vector2 )
voidon_look_state( kind: LookBinding.Kind, active: bool )
voidhandle_zoom( steps: int )
voidset_target( target: Variant, use_pan: bool = true )
voidcleanup()
Vector3get_camera_position()
Vector3get_camera_rotation()
floatget_view_yaw()
voidset_controller_for_validation( controller_logic: ControllerLogic )
Stringget_type_display_name()
Stringget_editor_icon()
Array[String]validate()

Property descriptions ​

String preset_name = "Unnamed Camera" ​

Display name shown in editor dropdowns

bool zoom_with_window_open = true ​

The camera zooms while a window (an inventory, a character sheet) is open. Off: the wheel and the zoom keys do nothing until the window is closed. A window of screen space 0 does not count

String description = "" ​

Description of camera behavior

Camera Socket

Vector3 initial_socket_position = Vector3.ZERO ​

Initial position of camera socket (parent node that moves/rotates)

Vector3 initial_socket_rotation_degrees = Vector3(-20.0, 0.0, 0.0) ​

Initial rotation of camera socket in degrees

Camera

Vector3 initial_camera_position = Vector3(0, 1.5, 3.5) ​

Initial Camera3D position (relative to socket)

Vector3 initial_camera_rotation_degrees = Vector3(-7.0, 0.0, 0.0) ​

Initial Camera3D rotation in degrees

Rendering

float field_of_view = 75.0 ​

Field of view in degrees

float near_clip = 0.05 ​

Near clipping plane

float far_clip = 500.0 ​

Far clipping plane (view distance)

Automatic Shake

bool shake_on_landing = false ​

The camera shakes when the character lands from a fall. Off by default; the player's Camera shake setting scales it

float landing_min_height = 3.0 ​

Falls shorter than this (metres) do not shake the camera

float landing_shake_amount = 0.3 ​

How hard a landing shakes at the shortest fall that shakes (0 to 1); a longer fall shakes more, up to 1

bool shake_on_big_hit = false ​

The camera shakes when the character takes a big hit. Off by default

float big_hit_min_percent = 15.0 ​

A hit shakes the camera when it takes at least this many percent of the character's health at once

float big_hit_shake_amount = 0.4 ​

How hard a big hit shakes (0 to 1)

Zoom

float zoom_min = 3.0 ​

Minimum zoom distance

float zoom_max = 10.0 ​

Maximum zoom distance

float zoom_speed = 2.0 ​

Zoom input speed

float zoom_smoothing = 0.1 ​

Zoom smoothing (0=instant, 1=very smooth)

Follow Behavior

float follow_speed = 5.0 ​

Follow speed multiplier

float follow_smoothing = 0.95 ​

Follow smoothing (higher=smoother/slower)

float follow_distance_threshold = 0.1 ​

Distance threshold to stop following

Target Lock

bool enable_target_lock = true ​

Enable camera lock to player's locked target

float target_lock_rotation_speed = 8.0 ​

Speed at which camera rotates to target when locked

float target_lock_screen_offset = 0.1 ​

Keep target this far from screen center (0 = center, 0.3 = offset)

Input

float look_sensitivity_scale = 1.0 ​

How sensitive THIS preset feels, relative to the player's mouse sensitivity setting (SettingsConfig.mouse_x/y_axis_sensitivity). 1.0 = exactly the player's setting. Used by cameras that receive look input from the InputManager (uses_input_manager()).

Variable descriptions ​

GameHost.SystemHub system_hub ​

System hub reference (set at runtime)

CameraController camera_manager ​

The camera controller this logic moves.

bool is_locked_to_target = false ​

Target lock state

Variant locked_target = null ​

The target the player has locked, if any.

Method descriptions ​

void initialize( p_system_hub: GameHost.SystemHub ) ​

Initialize with system hub reference - called by CameraController

void bind_lock_source( player: Variant ) ​

Follows a player's target lock. Call from set_target with the new target: it disconnects the previous player, connects the new one and picks up the lock state it already has.

void unbind_lock_source() ​

Stops following the lock of a player.

void apply_to_camera_manager( camera_manager: CameraController ) ​

Apply settings to CameraController nodes

void setup( camera_manager: CameraController ) ​

Setup camera behavior - override in child classes

void process_camera( delta: float ) ​

Per-frame camera update - override in child classes

void handle_input( event: InputEvent ) ​

DEPRECATED raw input path. All shipped camera presets use the InputManager contract below; this is only called for custom cameras whose uses_input_manager() is false, so they keep working. Delivered by InputManager (after the GUI for presses/motion, before it for releases).

bool uses_input_manager() ​

true = this camera receives look/zoom from the InputManager instead of raw events

Array[LookBinding] get_look_bindings() ​

Mouse gestures this camera wants (button + LookBinding.Kind)

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

Look movement for a gesture this camera declared. delta_rad is screen-space radians with the player's sensitivity and invert settings applied (x > 0 = mouse right, y > 0 = mouse down). Multiply by look_sensitivity_scale.

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

A gesture this camera declared started (active = true) or ended (active = false)

void handle_zoom( steps: int ) ​

Mouse wheel notches. > 0 = zoom in, < 0 = zoom out

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

Set camera target - override in child classes

void cleanup() ​

Cleanup when switching cameras - override in child classes

Vector3 get_camera_position() ​

Get camera position - override in child classes

Vector3 get_camera_rotation() ​

Get camera rotation - override in child classes

float get_view_yaw() ​

The yaw the view is facing, in radians, in the same convention as Node3D.rotation.y (forward = -Z rotated by yaw). Read-only for controllers: camera-relative movement and "snap the body to the camera" use it. Cameras with their own yaw state override this.

void set_controller_for_validation( controller_logic: ControllerLogic ) ​

Editor / validation only: pretend this controller is the active one, so get_look_bindings() can be evaluated for a pairing without a running game. Pass null to clear.

String get_type_display_name() ​

Get display name for editor

String get_editor_icon() ​

Get icon for editor

Array[String] validate() ​

Validate settings - return errors array