[PR #2128] [MERGED] Server players' camera tilts towards the hit #4031

Closed
opened 2026-11-03 04:14:09 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2128
Author: @kacpherek
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/27/2026
Merged by: @ludovic111

Base: main ← Head: fix/remote-hurt-tilt


📝 Commits (3)

  • 4825e53 Tilt a server player's camera towards the hit
  • ed9fdb5 Point an explosion's hurt tilt at the blast
  • 9809bf3 Merge main into fix/remote-hurt-tilt

📊 Changes

6 files changed (+47 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+4 -0)
📝 crates/horizon-client/src/game/explosion.rs (+6 -0)
📝 crates/horizon-client/src/game/fov.rs (+1 -1)
📝 crates/horizon-client/src/game/lan_actions.rs (+7 -0)
📝 crates/horizon-client/src/game/remote.rs (+2 -1)
📝 crates/horizon-client/src/health.rs (+27 -0)

📄 Description

What and why

On a server (including the in-process server that single player runs on), a hit flashed the screen but the camera never tilted towards where it came from. The server did not send ClientboundHurtAnimationPacket anywhere, and the client's arm for it dropped the yaw.

  • PlayerHealth gets indicate_damage (the direction of a hit relative to the player's yaw, as ServerPlayer.indicateDamage computes it) and animate_hurt_dir (the client side, which keeps the yaw as Player.hurtDir).
  • mob_hits_player, which every mob, projectile and player hit goes through, records the direction when the default knockback is dealt and the hit was not blocked. hurt_blocking records the no-direction case (xd and zd zero, so the yaw is the player's yaw negated) for hits that have no source position; a hit with a position replaces it.
  • When a guest's turn ends (leave_guest) the pending direction goes out as HurtAnimation to that guest.
  • The client arm calls animate_hurt_dir(yaw), and bob_matrix passes hurt_dir to bobHurt instead of the fixed 0.0.

The window's own player in a single-player or host session is unchanged: nothing sets its hurt_dir, so it still tilts around 0 as before.

Vanilla reference

  • ServerPlayer.indicateDamage: hurtDir = atan2(zd, xd) * 180 / PI - yRot, then ClientboundHurtAnimationPacket(this).
  • LivingEntity.dealDefaultKnockback: calls indicateDamage(xd, zd) unless blocked.
  • ClientPacketListener.handleHurtAnimation and Player.animateHurt(yaw): restart the hurt time and keep hurtDir.
  • GameRenderer.bobHurt: rotates around hurtDir for the tilt.

Self-check

cargo check -p horizon-client passes.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/2128 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/27/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/remote-hurt-tilt` --- ### 📝 Commits (3) - [`4825e53`](https://github.com/horizon-rust/horizon/commit/4825e537ccc51d123bcc0f97d777e3330a570f52) Tilt a server player's camera towards the hit - [`ed9fdb5`](https://github.com/horizon-rust/horizon/commit/ed9fdb5208fbf2e0fadf1722a376746350827741) Point an explosion's hurt tilt at the blast - [`9809bf3`](https://github.com/horizon-rust/horizon/commit/9809bf38b60c39930161f28e51e15e550b5353b4) Merge main into fix/remote-hurt-tilt ### 📊 Changes **6 files changed** (+47 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+4 -0) 📝 `crates/horizon-client/src/game/explosion.rs` (+6 -0) 📝 `crates/horizon-client/src/game/fov.rs` (+1 -1) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+7 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+2 -1) 📝 `crates/horizon-client/src/health.rs` (+27 -0) </details> ### 📄 Description ## What and why On a server (including the in-process server that single player runs on), a hit flashed the screen but the camera never tilted towards where it came from. The server did not send `ClientboundHurtAnimationPacket` anywhere, and the client's arm for it dropped the yaw. - `PlayerHealth` gets `indicate_damage` (the direction of a hit relative to the player's yaw, as `ServerPlayer.indicateDamage` computes it) and `animate_hurt_dir` (the client side, which keeps the yaw as `Player.hurtDir`). - `mob_hits_player`, which every mob, projectile and player hit goes through, records the direction when the default knockback is dealt and the hit was not blocked. `hurt_blocking` records the no-direction case (`xd` and `zd` zero, so the yaw is the player's yaw negated) for hits that have no source position; a hit with a position replaces it. - When a guest's turn ends (`leave_guest`) the pending direction goes out as `HurtAnimation` to that guest. - The client arm calls `animate_hurt_dir(yaw)`, and `bob_matrix` passes `hurt_dir` to `bobHurt` instead of the fixed `0.0`. The window's own player in a single-player or host session is unchanged: nothing sets its `hurt_dir`, so it still tilts around 0 as before. ## Vanilla reference - `ServerPlayer.indicateDamage`: `hurtDir = atan2(zd, xd) * 180 / PI - yRot`, then `ClientboundHurtAnimationPacket(this)`. - `LivingEntity.dealDefaultKnockback`: calls `indicateDamage(xd, zd)` unless `blocked`. - `ClientPacketListener.handleHurtAnimation` and `Player.animateHurt(yaw)`: restart the hurt time and keep `hurtDir`. - `GameRenderer.bobHurt`: rotates around `hurtDir` for the tilt. ## Self-check `cargo check -p horizon-client` passes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:14:09 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#4031
No description provided.