Use frontal steering-wheel roll for Space Shooter movement.
Drop the interactive accel calibration and map left/right ship motion from absolute pod roll while held facing the player. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -60,12 +60,24 @@ func _process(_delta: float) -> void:
|
||||
_pod.basis = _pod.basis.slerp(_target_basis, SMOOTH)
|
||||
|
||||
|
||||
## Lenkrad-Roll in Radiant (links positiv). 0 wenn liegend oder in der Deadzone.
|
||||
static func steer_roll(accel: Vector3, deadzone_rad: float = deg_to_rad(12.0)) -> float:
|
||||
if accel.length() < MIN_ACCEL_LEN:
|
||||
return 0.0
|
||||
var n := accel.normalized()
|
||||
var face_t := clampf(1.0 - maxf(n.z, 0.0), 0.0, 1.0)
|
||||
if face_t < 0.25:
|
||||
return 0.0
|
||||
var roll := atan2(-n.x, -n.y)
|
||||
if absf(roll) <= deadzone_rad:
|
||||
return 0.0
|
||||
return signf(roll) * (absf(roll) - deadzone_rad) * face_t
|
||||
|
||||
|
||||
func _basis_from_accel(accel: Vector3) -> Basis:
|
||||
var n := accel.normalized()
|
||||
# 0 = liegend (+Z), 1 = aufgerichtet / gedreht (wenig +Z)
|
||||
var face_t := clampf(1.0 - maxf(n.z, 0.0), 0.0, 1.0)
|
||||
var b := _basis_flat.slerp(_basis_facing, face_t)
|
||||
# Lenkrad-Roll in der Sensor-XY-Ebene:
|
||||
# facing (0,−1) → 0; links (−1,0) → +π/2; rechts (+1,0) → −π/2
|
||||
var roll := atan2(-n.x, -n.y)
|
||||
return Basis(Quaternion(Vector3.BACK, roll * face_t)) * b
|
||||
|
||||
Reference in New Issue
Block a user