Camera feels fantastic
This commit is contained in:
@@ -13,6 +13,7 @@ const COLLISION_MARGIN:float = 0.3
|
||||
@export var minDistance:float = 2.0
|
||||
@export var orbitSensitivity:float = 144.0
|
||||
@export var orbitAcceleration:float = 600.0
|
||||
@export var orbitFriction:float = 10.0
|
||||
@export var pitchMin:float = -80.0
|
||||
@export var pitchMax:float = 70.0
|
||||
|
||||
@@ -63,15 +64,15 @@ func _process(delta:float) -> void:
|
||||
_mode = CameraMode.FREE
|
||||
_freeTimer = 0.0
|
||||
|
||||
# Controller input with speed ramp; instant stop on release
|
||||
# Controller input: ramp up to target speed, then friction-dampen on release
|
||||
if controllerActive:
|
||||
_camVelocity = _camVelocity.move_toward(
|
||||
orbitInput * orbitSensitivity * SETTINGS.cameraSpeedController, orbitAcceleration * delta
|
||||
)
|
||||
_yaw += _camVelocity.x * delta * xMult
|
||||
_pitch += _camVelocity.y * delta * yMult
|
||||
else:
|
||||
_camVelocity = Vector2.ZERO
|
||||
_camVelocity = _camVelocity.lerp(Vector2.ZERO, minf(orbitFriction * delta, 1.0))
|
||||
_yaw += _camVelocity.x * delta * xMult
|
||||
_pitch += _camVelocity.y * delta * yMult
|
||||
|
||||
# Right-click mouse drag
|
||||
if mouseActive:
|
||||
@@ -130,7 +131,7 @@ func _process(delta:float) -> void:
|
||||
var actualDir:Vector3 = (finalPos - pivot).normalized()
|
||||
var targetPitch:float = rad_to_deg(asin(clamp(actualDir.y, -1.0, 1.0)))
|
||||
var targetYaw:float = rad_to_deg(atan2(actualDir.x, actualDir.z))
|
||||
var feedbackRate:float = minf(20.0 * delta, 1.0)
|
||||
var feedbackRate:float = minf(40.0 * delta, 1.0)
|
||||
_pitch = lerpf(_pitch, targetPitch, feedbackRate)
|
||||
var feedbackYawDiff:float = fposmod(targetYaw - _yaw + 180.0, 360.0) - 180.0
|
||||
_yaw += lerpf(0.0, feedbackYawDiff, feedbackRate)
|
||||
|
||||
Reference in New Issue
Block a user