From 5d68512994628613d8962c1ce446d11a63a376e9 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 11:08:07 +0100 Subject: [PATCH] Keep the body facing forward when a player walks backwards --- crates/horizon-client/src/game/lan.rs | 14 +++++++++++--- crates/horizon-client/src/game/perspective.rs | 10 +++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/crates/horizon-client/src/game/lan.rs b/crates/horizon-client/src/game/lan.rs index a0f99bfca..1c9ee2dc1 100644 --- a/crates/horizon-client/src/game/lan.rs +++ b/crates/horizon-client/src/game/lan.rs @@ -1520,10 +1520,18 @@ impl Game<'_> { m.head_yaw = g.head_yaw; m.head_pitch = g.pitch; let mut target = m.body_yaw; - if dx * dx + dz * dz > 0.002_500_000_2 { - target = (dz.atan2(dx) as f32).to_degrees() - 90.0; - } let wrap = |a: f32| (a + 180.0).rem_euclid(360.0) - 180.0; + if dx * dx + dz * dz > 0.002_500_000_2 { + // LivingEntity.tick: walking backwards the body faces away + // from the walk direction, not along it. + let walk = (dz.atan2(dx) as f32).to_degrees() - 90.0; + let facing = (wrap(g.yaw) - walk).abs(); + target = if 95.0 < facing && facing < 265.0 { + walk - 180.0 + } else { + walk + }; + } m.body_yaw += wrap(target - m.body_yaw) * 0.3; let diff = wrap(g.yaw - m.body_yaw); if diff.abs() > 50.0 { diff --git a/crates/horizon-client/src/game/perspective.rs b/crates/horizon-client/src/game/perspective.rs index caf49883b..2956f8162 100644 --- a/crates/horizon-client/src/game/perspective.rs +++ b/crates/horizon-client/src/game/perspective.rs @@ -372,7 +372,15 @@ impl Game<'_> { m.head_pitch = pitch; let mut target = m.body_yaw; if dx * dx + dz * dz > 0.002_500_000_2 { - target = (dz.atan2(dx) as f32).to_degrees() - 90.0; + // LivingEntity.tick: walking backwards the body faces away from + // the walk direction, not along it. + let walk = (dz.atan2(dx) as f32).to_degrees() - 90.0; + let facing = (wrap(yaw) - walk).abs(); + target = if 95.0 < facing && facing < 265.0 { + walk - 180.0 + } else { + walk + }; } if swinging { target = yaw;