Now About Social Code
summaryrefslogtreecommitdiff
path: root/addons/third-person-camera
diff options
context:
space:
mode:
authorLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2025-02-07 18:02:39 +0000
committerLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2025-02-07 18:02:39 +0000
commitb46b56c7998270f383c248b0224e5d23cadd01e0 (patch)
treeb92797ded918b0c5dcd49a7ec1fd10c4ff8096b3 /addons/third-person-camera
parent3acc9bee54ec9c96403b0b4a54983c4ad76530dc (diff)
Improve climbing
Implement new follow camera logic that makes the climbing logic easier to implement. Also ensure player can climb around corners.
Diffstat (limited to 'addons/third-person-camera')
-rw-r--r--addons/third-person-camera/third_person_camera/ThirdPersonCamera.gd8
-rw-r--r--addons/third-person-camera/third_person_camera/ThirdPersonCamera.tscn6
2 files changed, 10 insertions, 4 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") :
diff --git a/addons/third-person-camera/third_person_camera/ThirdPersonCamera.tscn b/addons/third-person-camera/third_person_camera/ThirdPersonCamera.tscn
index f1faf2e..f59b361 100644
--- a/addons/third-person-camera/third_person_camera/ThirdPersonCamera.tscn
+++ b/addons/third-person-camera/third_person_camera/ThirdPersonCamera.tscn
@@ -25,7 +25,7 @@ transform = Transform3D(1, 0, 0, 0, 0.939693, 0.34202, 0, -0.34202, 0.939693, 0,
top_level = true
[node name="OffsetPivot" type="Node3D" parent="RotationPivot"]
-transform = Transform3D(1, -3.9187e-07, 6.47546e-10, 3.94476e-07, 1, 5.65946e-05, -2.27374e-11, -5.65946e-05, 1, 0, 0, 0)
+transform = Transform3D(1, -3.9187e-07, 6.47546e-10, 3.94476e-07, 1, 5.65648e-05, -2.27374e-11, -5.65648e-05, 1, 0, 0, 0)
[node name="CameraSpringArm" type="SpringArm3D" parent="RotationPivot/OffsetPivot"]
process_priority = 11
@@ -33,14 +33,14 @@ shape = SubResource("SeparationRayShape3D_84uqy")
spring_length = 10.0
[node name="CameraMarker" type="Marker3D" parent="RotationPivot/OffsetPivot/CameraSpringArm"]
-transform = Transform3D(1, 7.93407e-08, 3.5101e-07, 1.48521e-08, 1, -7.89762e-06, 2.08538e-07, 1.2219e-06, 1, -6.69741e-09, -0.000566006, 9.99999)
+transform = Transform3D(1, 7.93283e-08, 3.5101e-07, 1.48522e-08, 0.999999, -8.73208e-06, 2.08538e-07, 1.2517e-06, 0.999999, -6.69706e-09, -0.000566006, 10)
[node name="PivotDebug" type="MeshInstance3D" parent="RotationPivot/OffsetPivot"]
visible = false
mesh = SubResource("SphereMesh_ag7lb")
[node name="Camera" type="Camera3D" parent="."]
-transform = Transform3D(1, 5.38245e-15, -1.47882e-14, 0, 0.939693, 0.34202, 1.57372e-14, -0.34202, 0.939693, -1.47882e-13, 3.4202, 9.39693)
+transform = Transform3D(1, -7.09579e-15, 1.94955e-14, 0, 0.939693, 0.34202, -2.07467e-14, -0.34202, 0.939693, 1.94955e-13, 3.4202, 9.39693)
top_level = true
[node name="CameraDebug" type="MeshInstance3D" parent="Camera"]