From b46b56c7998270f383c248b0224e5d23cadd01e0 Mon Sep 17 00:00:00 2001 From: Lucas Fryzek Date: Fri, 7 Feb 2025 18:02:39 +0000 Subject: Improve climbing Implement new follow camera logic that makes the climbing logic easier to implement. Also ensure player can climb around corners. --- .../third-person-camera/third_person_camera/ThirdPersonCamera.gd | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'addons/third-person-camera/third_person_camera/ThirdPersonCamera.gd') diff --git a/addons/third-person-camera/third_person_camera/ThirdPersonCamera.gd b/addons/third-person-camera/third_person_camera/ThirdPersonCamera.gd index a460835..7eab1e2 100644 --- a/addons/third-person-camera/third_person_camera/ThirdPersonCamera.gd +++ b/addons/third-person-camera/third_person_camera/ThirdPersonCamera.gd @@ -102,7 +102,13 @@ func _process_horizontal_rotation_input() : var camera_horizontal_rotation_variation = Input.get_action_strength("tp_camera_right") - Input.get_action_strength("tp_camera_left") camera_horizontal_rotation_variation = camera_horizontal_rotation_variation * get_process_delta_time() * 30 * horizontal_rotation_sensitiveness camera_horizontal_rotation_deg += camera_horizontal_rotation_variation - + +func focus_camera(local_pos: Vector3, target_pos: Vector3): + var local_2d = Vector2(local_pos.x, local_pos.z) + var target_2d = Vector2(target_pos.x, target_pos.z) + # This is the amount to tween the camera position + var target_rotation = target_2d.angle_to_point(local_2d) + PI/2.0 + camera_horizontal_rotation_deg = rad_to_deg(_camera.global_rotation.y - target_rotation) func _process_tilt_input() : if InputMap.has_action("tp_camera_up") and InputMap.has_action("tp_camera_down") : -- cgit