Improve camera responsiveness by following one frame ahead laterally and 20 frames ahead vertically -- the latter to improve vantage when jumping or taking springboards.

This commit is contained in:
blujai831 2025-03-30 15:35:16 -07:00
parent ce77112c20
commit 5ef367cac2
No known key found for this signature in database
GPG Key ID: DDC31A0363AA5E66
1 changed files with 9 additions and 2 deletions

View File

@ -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(