From 5ef367cac2efc2dec80a3feada3be9f8e65ed200 Mon Sep 17 00:00:00 2001 From: blujai831 Date: Sun, 30 Mar 2025 15:35:16 -0700 Subject: [PATCH] Improve camera responsiveness by following one frame ahead laterally and 20 frames ahead vertically -- the latter to improve vantage when jumping or taking springboards. --- vfx/gameplay_camera.gd | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/vfx/gameplay_camera.gd b/vfx/gameplay_camera.gd index 26754f4..acafd26 100644 --- a/vfx/gameplay_camera.gd +++ b/vfx/gameplay_camera.gd @@ -5,6 +5,7 @@ class_name GameplayCamera extends Camera3D @export var target_min_distance: float = 2.0 @export var target_max_distance: float = 10.0 @export var target_decentering_factor: float = 0.4 +@export var target_leveling_bias: float = 20.0 @export var follow_lerp_speed: float = 0.999 @export var turn_lerp_speed: float = 0.999 @export var fov_lerp_speed: float = 0.999 @@ -117,8 +118,14 @@ func _follow_target( if target is Character: top_speed = (target as Character).get_top_speed() var decentering: float = target_distance*target_decentering_factor + var leveling := ( + target_leveling_bias*velocity.project(target.global_basis.y) + )*delta var target_position := ( - target.global_position + decentering*target.global_basis.y + target.global_position + + decentering*target.global_basis.y + + velocity*delta + + leveling ) var target_offset := target_position - global_position if !snap: @@ -130,7 +137,7 @@ func _follow_target( )) if abs(_gimbal_check()) <= lerp(gimbal_margin, 1.0, 0.5): var desired_basis := Basis.looking_at( - target_offset, + target_offset - leveling, target.global_basis.y ) global_basis = desired_basis if snap else global_basis.slerp(