From 142968038c3d21bdc910c88e35a8547d42ad537c Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 26 Sep 2026 15:28:44 +0200 Subject: [PATCH] Unify pod steering on lateral X tilt for flat and frontal holds. Replace facing-only roll detection with atan2(x, yz) so left/right works in both orientations without a face gate. Co-authored-by: Cursor --- scenes/space_shooter.tscn | 2 +- scripts/orientation_gizmo.gd | 18 ++++++++---------- scripts/space_shooter.gd | 11 +++++------ 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/scenes/space_shooter.tscn b/scenes/space_shooter.tscn index 5389dde..d895d07 100644 --- a/scenes/space_shooter.tscn +++ b/scenes/space_shooter.tscn @@ -89,7 +89,7 @@ layout_mode = 2 theme_override_colors/font_color = Color(0.6, 0.65, 0.75, 1) theme_override_font_sizes/font_size = 14 horizontal_alignment = 1 -text = "Split-Screen · Pod frontal halten, Lenkrad drehen" +text = "Split-Screen · kippen oder Lenkrad drehen" [node name="ClientGrid" type="GridContainer" parent="UiLayer/SetupPanel"] layout_mode = 2 diff --git a/scripts/orientation_gizmo.gd b/scripts/orientation_gizmo.gd index aa42ae1..d09a2f9 100644 --- a/scripts/orientation_gizmo.gd +++ b/scripts/orientation_gizmo.gd @@ -60,18 +60,16 @@ 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: +## Lateral tip in radians about device X. +## Positive = tip toward +X (works for flat left/right tilt and frontal wheel turn). +static func steer_roll(accel: Vector3, deadzone_rad: float = deg_to_rad(8.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: + var angle := atan2(n.x, sqrt(n.y * n.y + n.z * n.z)) + if absf(angle) <= deadzone_rad: 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 + return signf(angle) * (absf(angle) - deadzone_rad) func _basis_from_accel(accel: Vector3) -> Basis: @@ -79,5 +77,5 @@ func _basis_from_accel(accel: Vector3) -> Basis: # 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) - var roll := atan2(-n.x, -n.y) - return Basis(Quaternion(Vector3.BACK, roll * face_t)) * b + var lateral := atan2(n.x, sqrt(n.y * n.y + n.z * n.z)) + return Basis(Quaternion(Vector3.BACK, -lateral)) * b diff --git a/scripts/space_shooter.gd b/scripts/space_shooter.gd index bf19484..1832aa6 100644 --- a/scripts/space_shooter.gd +++ b/scripts/space_shooter.gd @@ -250,7 +250,7 @@ func _on_client_selection_changed(_idx: int) -> void: setup_hint_label.text = "Links und rechts müssen verschiedene Pods sein." else: setup_hint_label.text = ( - "Pod #%d links · Pod #%d rechts · frontal halten, Lenkrad drehen" + "Pod #%d links · Pod #%d rechts · kippen oder Lenkrad drehen" % [_left_client_id, _right_client_id] ) @@ -284,7 +284,7 @@ func _begin_playing() -> void: _enable_both_streams() _update_score_labels() status_label.text = ( - "Pod frontal halten · wie Lenkrad drehen · Tap = Boost (%ds)" + "Pod halten · links/rechts kippen oder Lenkrad · Tap = Boost (%ds)" % int(BOOST_DURATION_SEC) ) @@ -694,10 +694,9 @@ func _update_stars(delta: float) -> void: func _effective_accel(side: int) -> float: - # Frontal halten, Lenkrad-Roll: links positiv → Schiff nach links (negativ). + # Lateral +X → Schiff nach rechts (flach kippen und frontal Lenkrad). var a := _accel_for_side(side) - var roll := OrientationGizmo.steer_roll(Vector3(a)) - return -roll * STEER_GAIN + return OrientationGizmo.steer_roll(Vector3(a)) * STEER_GAIN func _velocity_scale(side: int) -> float: @@ -734,7 +733,7 @@ func _update_connection_status() -> void: match _socket.get_ready_state(): WebSocketPeer.STATE_OPEN: status_label.text = ( - "Frontal halten · Lenkrad drehen · Tap = Boost (%ds) · ♥×%d · CD %ds" + "Kippen / Lenkrad · Tap = Boost (%ds) · ♥×%d · CD %ds" % [int(BOOST_DURATION_SEC), MAX_LIVES, int(BOOST_COOLDOWN_SEC)] ) WebSocketPeer.STATE_CONNECTING: