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:
Add exported properties for configuration
Override setup/process_camera/handle_input for behavior
Override get_type_display_name() for editor display
Properties ​
String | preset_name | "Unnamed Camera" |
bool | zoom_with_window_open | true |
String | description | "" |
Vector3 | initial_socket_position | Vector3.ZERO |
Vector3 | initial_socket_rotation_degrees | Vector3(-20.0, 0.0, 0.0) |
Vector3 | initial_camera_position | Vector3(0, 1.5, 3.5) |
Vector3 | initial_camera_rotation_degrees | Vector3(-7.0, 0.0, 0.0) |
float | field_of_view | 75.0 |
float | near_clip | 0.05 |
float | far_clip | 500.0 |
bool | shake_on_landing | false |
float | landing_min_height | 3.0 |
float | landing_shake_amount | 0.3 |
bool | shake_on_big_hit | false |
float | big_hit_min_percent | 15.0 |
float | big_hit_shake_amount | 0.4 |
float | zoom_min | 3.0 |
float | zoom_max | 10.0 |
float | zoom_speed | 2.0 |
float | zoom_smoothing | 0.1 |
float | follow_speed | 5.0 |
float | follow_smoothing | 0.95 |
float | follow_distance_threshold | 0.1 |
bool | enable_target_lock | true |
float | target_lock_rotation_speed | 8.0 |
float | target_lock_screen_offset | 0.1 |
float | look_sensitivity_scale | 1.0 |
Variables ​
GameHost.SystemHub | system_hub | |
CameraController | camera_manager | |
bool | is_locked_to_target | false |
Variant | locked_target | null |
Methods ​
void | initialize( p_system_hub: GameHost.SystemHub ) |
void | bind_lock_source( player: Variant ) |
void | unbind_lock_source() |
void | apply_to_camera_manager( camera_manager: CameraController ) |
void | setup( camera_manager: CameraController ) |
void | process_camera( delta: float ) |
void | handle_input( event: InputEvent ) |
bool | uses_input_manager() |
Array[LookBinding] | get_look_bindings() |
void | handle_look( kind: LookBinding.Kind, delta_rad: Vector2 ) |
void | on_look_state( kind: LookBinding.Kind, active: bool ) |
void | handle_zoom( steps: int ) |
void | set_target( target: Variant, use_pan: bool = true ) |
void | cleanup() |
Vector3 | get_camera_position() |
Vector3 | get_camera_rotation() |
float | get_view_yaw() |
void | set_controller_for_validation( controller_logic: ControllerLogic ) |
String | get_type_display_name() |
String | get_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