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 <cursoragent@cursor.com>
This commit is contained in:
@@ -89,7 +89,7 @@ layout_mode = 2
|
|||||||
theme_override_colors/font_color = Color(0.6, 0.65, 0.75, 1)
|
theme_override_colors/font_color = Color(0.6, 0.65, 0.75, 1)
|
||||||
theme_override_font_sizes/font_size = 14
|
theme_override_font_sizes/font_size = 14
|
||||||
horizontal_alignment = 1
|
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"]
|
[node name="ClientGrid" type="GridContainer" parent="UiLayer/SetupPanel"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|||||||
@@ -60,18 +60,16 @@ func _process(_delta: float) -> void:
|
|||||||
_pod.basis = _pod.basis.slerp(_target_basis, SMOOTH)
|
_pod.basis = _pod.basis.slerp(_target_basis, SMOOTH)
|
||||||
|
|
||||||
|
|
||||||
## Lenkrad-Roll in Radiant (links positiv). 0 wenn liegend oder in der Deadzone.
|
## Lateral tip in radians about device X.
|
||||||
static func steer_roll(accel: Vector3, deadzone_rad: float = deg_to_rad(12.0)) -> float:
|
## 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:
|
if accel.length() < MIN_ACCEL_LEN:
|
||||||
return 0.0
|
return 0.0
|
||||||
var n := accel.normalized()
|
var n := accel.normalized()
|
||||||
var face_t := clampf(1.0 - maxf(n.z, 0.0), 0.0, 1.0)
|
var angle := atan2(n.x, sqrt(n.y * n.y + n.z * n.z))
|
||||||
if face_t < 0.25:
|
if absf(angle) <= deadzone_rad:
|
||||||
return 0.0
|
return 0.0
|
||||||
var roll := atan2(-n.x, -n.y)
|
return signf(angle) * (absf(angle) - deadzone_rad)
|
||||||
if absf(roll) <= deadzone_rad:
|
|
||||||
return 0.0
|
|
||||||
return signf(roll) * (absf(roll) - deadzone_rad) * face_t
|
|
||||||
|
|
||||||
|
|
||||||
func _basis_from_accel(accel: Vector3) -> Basis:
|
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)
|
# 0 = liegend (+Z), 1 = aufgerichtet / gedreht (wenig +Z)
|
||||||
var face_t := clampf(1.0 - maxf(n.z, 0.0), 0.0, 1.0)
|
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 b := _basis_flat.slerp(_basis_facing, face_t)
|
||||||
var roll := atan2(-n.x, -n.y)
|
var lateral := atan2(n.x, sqrt(n.y * n.y + n.z * n.z))
|
||||||
return Basis(Quaternion(Vector3.BACK, roll * face_t)) * b
|
return Basis(Quaternion(Vector3.BACK, -lateral)) * b
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ func _on_client_selection_changed(_idx: int) -> void:
|
|||||||
setup_hint_label.text = "Links und rechts müssen verschiedene Pods sein."
|
setup_hint_label.text = "Links und rechts müssen verschiedene Pods sein."
|
||||||
else:
|
else:
|
||||||
setup_hint_label.text = (
|
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]
|
% [_left_client_id, _right_client_id]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -284,7 +284,7 @@ func _begin_playing() -> void:
|
|||||||
_enable_both_streams()
|
_enable_both_streams()
|
||||||
_update_score_labels()
|
_update_score_labels()
|
||||||
status_label.text = (
|
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)
|
% int(BOOST_DURATION_SEC)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -694,10 +694,9 @@ func _update_stars(delta: float) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _effective_accel(side: int) -> float:
|
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 a := _accel_for_side(side)
|
||||||
var roll := OrientationGizmo.steer_roll(Vector3(a))
|
return OrientationGizmo.steer_roll(Vector3(a)) * STEER_GAIN
|
||||||
return -roll * STEER_GAIN
|
|
||||||
|
|
||||||
|
|
||||||
func _velocity_scale(side: int) -> float:
|
func _velocity_scale(side: int) -> float:
|
||||||
@@ -734,7 +733,7 @@ func _update_connection_status() -> void:
|
|||||||
match _socket.get_ready_state():
|
match _socket.get_ready_state():
|
||||||
WebSocketPeer.STATE_OPEN:
|
WebSocketPeer.STATE_OPEN:
|
||||||
status_label.text = (
|
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)]
|
% [int(BOOST_DURATION_SEC), MAX_LIVES, int(BOOST_COOLDOWN_SEC)]
|
||||||
)
|
)
|
||||||
WebSocketPeer.STATE_CONNECTING:
|
WebSocketPeer.STATE_CONNECTING:
|
||||||
|
|||||||
Reference in New Issue
Block a user