From ea87e1149eb45e2ec2a48005a8a8b6dfd5b48ee0 Mon Sep 17 00:00:00 2001 From: jacobtkeio Date: Fri, 31 Oct 2025 08:00:10 +0000 Subject: [PATCH] Simplify push_box's camera height logic Problem: push_box.gd:_ready calls super() before setting the camera's position. super() modifies the camera's position by adding the dist_above_target offset, but setting the camera's position after makes this redundant. To fix this and apply the correct offset, the camera_controller_base class' _process function sets the camera's height to target.location.y + distance_above_target. However, this does not need to run in the _process function because neither the height of the target nor the distance_above_target change over time. To clean this up, do not override camera_controller_base:_ready in push_box.gd, make camera_controller_base:_ready set the position to the target's position + the vertical offset, and do not update the camera's vertical (y) position in the _process function. Then, the camera's height gets set correctly and only once (in push_box's inherited _ready function). --- Obscura/scripts/camera_controllers/camera_controller_base.gd | 5 +---- Obscura/scripts/camera_controllers/push_box.gd | 5 ----- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/Obscura/scripts/camera_controllers/camera_controller_base.gd b/Obscura/scripts/camera_controllers/camera_controller_base.gd index 381e208..2d86285 100644 --- a/Obscura/scripts/camera_controllers/camera_controller_base.gd +++ b/Obscura/scripts/camera_controllers/camera_controller_base.gd @@ -15,7 +15,7 @@ extends Camera3D func _ready() -> void: current = false - position += Vector3(0.0, dist_above_target, 0.0) + position = target.position + Vector3(0.0, dist_above_target, 0.0) func _process(delta: float) -> void: @@ -38,9 +38,6 @@ func _process(delta: float) -> void: #if abs(_camera_tilt_rad) < 0.01: #_camera_tilt_rad = 0.0 #rotation.z = _camera_tilt_rad - - position.y = target.position.y + dist_above_target - @abstract func _draw_logic() -> void diff --git a/Obscura/scripts/camera_controllers/push_box.gd b/Obscura/scripts/camera_controllers/push_box.gd index d47c15b..0fe85ad 100644 --- a/Obscura/scripts/camera_controllers/push_box.gd +++ b/Obscura/scripts/camera_controllers/push_box.gd @@ -6,11 +6,6 @@ extends CameraControllerBase @export var box_height:float = 10.0 -func _ready() -> void: - super() - position = target.position - - func _process(delta: float) -> void: if !current: return