Now About Social Code
summaryrefslogtreecommitdiff
path: root/addons/third-person-camera/third_person_camera/ThirdPersonCamera.gd
diff options
context:
space:
mode:
Diffstat (limited to 'addons/third-person-camera/third_person_camera/ThirdPersonCamera.gd')
-rw-r--r--addons/third-person-camera/third_person_camera/ThirdPersonCamera.gd8
1 files changed, 7 insertions, 1 deletions
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") :