Skip to content

feat: the hero jumps, falls and gets hurt like in Gothic - flat falls, lying landings, the running leap, fall damage only when he lands lying (#499) - #584

Open
BoroBongo wants to merge 43 commits into
fix/hero-speed-matches-stepsfrom
feature/hero-jump-fall
Open

BoroBongo wants to merge 43 commits into
fix/hero-speed-matches-stepsfrom
feature/hero-jump-fall

Conversation

@BoroBongo

@BoroBongo BoroBongo commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

What

Closes #499. The hero jumps, falls and gets hurt like in Gothic, and the VR body shows it.

  • Fall damage like the engine's, only when he lands lying. At the landing, from the highest point of the jump or fall: (drop - FALLDOWN_HEIGHT) x FALLDOWN_DAMAGE - PROT_FALL (5 m / 20 per m for humans). Nothing while in the air; landing on his feet costs nothing, also from high up (author's choice - HP lost without a fall on the face looked like a twisted ankle). A deep fall kills (FightService). Not in water, on teleports (also Marvin, scripts, loading, ledges/ladders), while climbing, transformed or in god mode. Always on, also without the combat system (no flag).
  • Falling flat. Walking off an edge deeper than 2 m (like NPCs), or a jump that lands deeper than FALLDOWN_HEIGHT below its take-off: S_FALL / S_FALLB in the air, then he lands lying on his face (or his back when he went over the edge backwards), lies a moment and gets up - walking and jumping locked meanwhile, a haptic pulse.
  • Jumps. Standing and walking: Gothic's jump-up (T_STAND_2_JUMPUP, S_JUMPUP) straight up, 1 m. Sprinting: the running jump - T_RUNL_2_JUMP and a leap at its root-motion speed (x1.4 like the run, about 7 m/s), the stick doesn't steer in the air. Take-offs play at their own speed and are cut by the landing. BS_JUMP / BS_FALL for the scripts.
  • Immersion option "Deep fall view" (heroLandingView): the view stays aside (default) or goes down and up with the body.
  • No jump while walking is blocked (lying after a fall, dialogs, knocked out) - decided in VRContextInteractionService for any backend.
  • No hand flicker in fast falls: the physical hands follow the rig's movement per physics step (VrPhysicsHand).
  • Owners: Core decides everything - the phases, the running jump (speed at take-off), the lying landing's timeline (HeroLanding.StandUpStart/End, the VR body follows it), the damage; VR only measures through IVrRig (also the ground snap height) and animates. NPCs and the hero share FallPose (HUMANS.MDS fall sets).

Technical: Core HeroFallService + HeroAirborneDomain (EditMode tests), models in Models/Movement (FallPose, HeroLanding, HeroFallHold, ...), event HeroLanded, PlayerLocks.FallLanding, BodyStateExtension (IsLocomotion/IsAirborne). VR: VrHeroJumpFall (measures via IVrRig: IsJumping, GroundSnapHeight, SetLeapVelocity), VrHeroLocomotion (air animations, listens to HeroLanded), VrHeroDownPose (one down reason + VrHeroDownAnimations), GothicJumpProvider (1 m rise, VRConstants.HeroNormalJumpRise), VRContextInteractionService (a blocked walk blocks jumping).

Stacked on #583 (fix/hero-speed-matches-steps).

ADR: Docs/adr/2026-11-29-hero-jump-fall.md

Why

#499 - the hero took no fall damage and his VR body showed no jumps or falls.

How to test manually

G1 Mroczne Tajemnice (a Gothic 1 mod) or vanilla G1/G2.

  • Standing jump: straight up about 1 m, jump-up animation, [HeroFall] Landed (jump) ... damage 0.
  • Sprint jump: a long leap, [VrHeroJumpFall] Running jump ... leap at ... and Leap ended ... after X m.
  • Walk off a 3 m edge: flat on the face, lies and gets up, lying landing on his face ... damage 0, walking and jumping locked about 1.7 s.
  • Walk backwards off an edge: lands on his back.
  • Sprint-jump down a steep slope (2-4 m below the take-off): lands on his feet, no damage.
  • 8-10 m: about (h - 5) x 20 damage, once. 20+ m: dies, death menu opens.
  • Jump or fall into water: swims, no damage. Marvin goto / thumbstick teleport mid-fall: no damage. Marvin god mode: "God mode: ... ignored".
  • Immersion "Deep fall view": aside / with body.
  • Fast fall: the hands don't flicker (also check in the headset build).
  • With EnableCombatSystem off: the hero is hurt, NPCs aren't (NpcJumpFall checks it where it raises the damage).

Save/load

Nothing is saved. A load resets the tracking and the lock; the first 2 s after a world load aren't tracked (bridges still loading).

Known gaps / follow-ups

  • Wiki: the new ini key heroLandingView (Immersion).
  • A transformed hero takes no fall damage (the monster's own rules aren't applied).
  • Reviews: .claude/review/feature-hero-jump-fall/ - two rounds (architecture: fits with concerns -> fits; gothic: no blockers), all findings fixed in this PR, the architecture ones included (one measurement of the take-off in Core, the lying timeline in Core, HeroLanded instead of polling, down reasons, FallPose incl. the upright fall, the ground snap from the rig, the flag removed). The leap direction now comes from Core's take-off velocity. Tested by the author in the headset: no hand flicker; a 36 m running jump kills and the death menu opens.

🤖 Generated with Claude Code

BoroBongo and others added 30 commits November 29, 2026 16:11
…rom the top of the jump or fall, none within FALLDOWN_HEIGHT, also without the combat system

HeroFallService (Core) tracks the hero's airborne phases from per-frame measurements
(HeroAirborneDomain), sets BS_JUMP/BS_FALL, computes the damage once at the landing with
NpcFallDomain.GetFallDamage and raises HeroLanded and FallDamage. Gated by
DeveloperConfig.EnableHeroFallDamage. FightService takes the hero's fall damage without the
combat system (NPCs unchanged), honours god mode for a hero without prefab properties and
never sets negative hit points. A deep landing locks walking (PlayerLocks.FallLanding).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…and gets hurt by deep falls - the rig port feeds HeroFallService

VrHeroJumpFall measures feet height, grounded (with the rig's grace), jumping (new
IVrRig.IsJumping, XRI's jump provider), climbing, gravity and teleports. A hero jumping or
falling into water swims (VRSwimDive takes BS_JUMP/BS_FALL over).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… S_JUMP, S_FALLDN/S_FALL and the small landings

VrHeroLocomotion follows HeroFallService's phase: T_STAND_2_JUMP or T_RUNL_2_JUMP (played in
0.3 s, the physics jump is already airborne) -> S_JUMP -> T_JUMP_2_STAND / T_JUMP_2_RUNL (or
straight on running), S_FALLDN -> S_FALL past FALLDOWN_HEIGHT -> T_FALLDN_2_STAND. Walking on
cuts a landing short. Stairs and slopes no longer show S_FALLDN (the old grounded/speed check).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…w stays at the head or goes with the body (Immersion option heroLandingView)

VrHeroDownPose plays T_FALL_2_FALLEN -> S_FALLEN -> T_FALLEN_2_STAND on a deep HeroLanded in
either heroFallMode, reusing its camera-down mechanism for heroLandingView 1; killed by the
fall he stays lying (S_DEAD). Both controllers give a short strong pulse on a deep landing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ad or a loaded game is no fall - the first 2 s aren't tracked

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ht (0.46, a force unit) lifted him only about 0.3 m

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ce, or on his back when he went over the edge backwards; the damage still starts at FALLDOWN_HEIGHT

The pose is decoupled from the damage: NpcFallDomain.LyingFallHeight (2 m, shared with
NpcJumpFall) switches to S_FALL / S_FALLB and a lying landing (HeroFallPose: T_FALL_2_FALLEN,
S_FALLEN, T_FALLEN_2_STAND or the FALLB/FALLENB set, S_DEAD/S_DEADB when it kills), the lock
lasts the chosen set's animations. Backwards = horizontal movement against the facing when the
fall turns flat; the face set if the model lacks the back one. A 3 m fall lands lying with
damage 0. HeroLanded carries the HeroLanding.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ace or the back, separate from the damage

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ort) and EnableHeroFallDamage on in Production

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… - the jump's own rise no longer lays the hero on his face

HeroAirborneDomain measures the lying depth of a jump from its take-off (LyingReferenceY), a
fall from its start; a jump stays a jump (S_JUMP, the jump's landing) until that deep. The
damage height is still from the top. Tests: a running jump down a slope landing 1.5 m lower
lands as a jump, a jump off a 3 m ledge lands lying.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…at T_RUNL_2_JUMP's speed in the direction of the run

VrHeroJumpFall starts the leap when a jump begins at or above VrHeroSpeeds.RunThreshold:
IVrRig.SetLeapVelocity (new port member) with VrHeroSpeeds.RunJump - T_RUNL_2_JUMP's root
motion at the body's scale (VrHeroLocomotion.UpdateSpeeds), else 1.6x the run. XriRig moves
the CharacterController at that velocity with the stick's movement off until it lands, climbs
or is teleported; water, a ledge or a teleport also end it from HeroFallService's phase. The
standing and walking jump stays vertical, both rise 1 m.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…m its take-off, the running jump leaps

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fall, dialogs, knocked out) - and a running jump logs how far it went

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…llows the rig's movement per physics step, not the frame's average

VrPhysicsHand.Drive followed _rigVelocity unlimited and the rest clamped to Max Speed (15 m/s).
_rigVelocity was measured per frame in LateUpdate, but the rig moves once per frame: in the
second physics step of a frame (editor below 50 fps) the controller stood still while the hand
was still driven at the rig's velocity; at 20 m/s the clamp left 5 m/s, the body overshot the
controller by ~10 cm, and beyond the 5 mm blocked distance UpdateVisual showed the interpolated
body one step behind - the hands jumped every few frames (no snap or stuck log: neither ran).
Now the rig's movement since the last step is measured in FixedUpdate. Also a rig move per
frame counts as a teleport only beyond (terminal fall speed + 5 m/s) * deltaTime, at least 1 m -
a fast fall at a low frame rate snapped the hands; real teleports raise Teleported anyway.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…UP), not Gothic's forward leap - and the take-off plays at its own speed until he lands

T_STAND_2_JUMP is Gothic's standing forward jump (2.65 m, flailing arms); the vertical VR jump
now uses the jump-up, T_STAND_2_JUMP / S_JUMP only for a model without it. The running jump
(VRPlayerService.IsRunningJump, set by VrHeroJumpFall with the leap - one decision for the leap
and the animation) keeps T_RUNL_2_JUMP -> S_JUMP. The take-off is no longer squeezed into
0.3 s: it plays at its own speed and the landing cuts it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…IGHT below the take-off - jumping down steep slopes no longer lays him on his face

Like OpenGothic, a jump falls flat (and lands lying) only beyond the guild's FALLDOWN_HEIGHT
(5 m human) below its take-off; a fall without a jump keeps NpcFallDomain.LyingFallHeight (2 m)
below its start. HeroAirborneDomain.Tick takes the safe height again for that (LyingDepth), the
damage stays from the top. Tests: a jump 3.5 m down a steep slope lands as a jump, a jump off
a 6 m ledge lands lying.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eir own speed, a jump falls flat only beyond FALLDOWN_HEIGHT

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… landing on his feet costs nothing, also from high up

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nsion IsLocomotion/IsAirborne) - HeroFallService, VRHeroMovement and VRSwimDive no longer copy the list

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o string per frame while he sits or lies - logged once when it changes, also in builds

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nding checks the depth again (a hitch at low frame rates landed him on his feet, unhurt)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he hero's death - not only by the platform's Tick, which may stop meanwhile

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ecks EnableCombatSystem like HeroFallService checks EnableHeroFallDamage, FightService only applies it

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y backend), not in the XRI rig - and the rig enables its move and jump providers in one place, the leap included, with null guards

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…oNormalJumpRise), not a backend literal

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hange mid-fall drops the fall, the landing re-checks the lying depth, a blocked walk blocks jumping, a drawn weapon changes nothing

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eroFallDamage was only for testing and goes

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ero's - and NpcJumpFall falls and lands with FallPose.Front instead of its own literals

Co-Authored-By: Claude Opus 5.5 <[email protected]>
BoroBongo and others added 7 commits November 29, 2026 16:11
…(HeroFallSample.GroundSnapHeight from IVrRig) - no Core constant mirroring the XRI rig's 0.3 m

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…Jump: the take-off's speed against HeroFallSample.RunSpeed) - VR only leaps, VRPlayerService.IsRunningJump goes

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ng while bound) - HeroFallService.LandingCount and LastLanding go, one channel for one fact

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e times it (HeroLanding.StandUpStart / StandUpEnd) and decides the back set once (LyingFallPose), VrHeroDownPose follows those times with one DownReason and an animation set per reason (VrHeroDownAnimations) instead of its own chain and four landing flags

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e, the hero's fall damage is always on

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…) in all 8 languages - aside or with the body (added through Unity MCP)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
BoroBongo and others added 6 commits November 29, 2026 16:24
…off velocity (HeroAirborneDomain/HeroFallService.TakeOffVelocity next to IsRunningJump), HeroFallService.Tick returns the event it handled and VrHeroJumpFall starts the leap on JumpStarted in that direction (its own smoothed velocity and phase-edge check are gone); tests for the take-off velocity

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…to the fall flat's - FallPose.FallDown / FallDownToStand, used by NpcJumpFall and VrHeroLocomotion instead of their own literals

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ends the VR body's lying too - VrHeroDownPose listens to IVrRig.Teleported, so the body no longer lies on after HeroFallService ended the walking lock

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…w menu comment wrapped to 120 columns

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…jump/fall code reads the hero's speeds from VRHeroSpeedService

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@BoroBongo

Copy link
Copy Markdown
Contributor Author

AI review (architecture-reviewer + gothic-reviewer), two rounds

Round Commit Architecture Gothic
1 6da9bd9b0 fits with concerns (8 minor) no blockers (8 risks + config/nits)
2 da03be8 fits: all 8 resolved, 2 new minor all resolved, 4 new minor
fixes 1f01390 all round-2 findings fixed

Fixed in this PR (nothing deferred):

  • Core decides, VR measures and performs:
    • the running jump and its direction come from one measurement in Core (TakeOffVelocity, the take-off speed against the run threshold);
    • the lying landing's timeline (HeroLanding.StandUpStart/End), which the VR body follows;
    • the back or face pose, checked once in Core;
    • the ground snap height comes from the rig port.
  • HeroLanded is the one channel to the VR body (no polling). VrHeroDownPose uses one down reason plus an animation set per reason.
  • FallPose (HUMANS.MDS fall sets, upright fall included) is shared by NPCs and the hero.
  • The EnableHeroFallDamage flag is removed: fall damage is always on, and only a lying landing hurts. NPC fall damage is switched where it is raised (EnableCombatSystem).
  • A blocked walk blocks jumping, for any backend (VRContextInteractionService). A teleport (ledge and ladder exits too) or his death ends the lock and the lying.
  • No per-frame strings (HeroFallHold). A drop past the lying depth in one step lands lying. Null guards on the leap.

Not changed:

  • The service's listeners are never removed: it's a ProjectScope singleton.
  • The wiki entry for the Immersion ini key heroLandingView (Player-Guide) is a separate wiki repository, to be added there.

Verified locally:

  • Compiles, 167/167 EditMode tests.
  • Editor playtest in G1 Mroczne Tajemnice (a Gothic 1 mod):
    • 3 m fall: flat, 0 damage;
    • 8.4 m fall: 68 damage;
    • running jump off a precipice (36 m): dead, death menu;
    • no exceptions.
  • Headset: no hand flicker.

Reports and answers: .claude/review/feature-hero-jump-fall/ (6da9bd9b0-, da03be8-).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant