Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ public bool AreAllQueued(Func<AbstractAnimationAction, bool> match)

// HINT: This information isn't set within Daedalus. We need to define it manually.
// HINT: i.e. every animation might have a BS. E.g. when AI_TakeItem() is called, we set BS.BS_TAKEITEM
public VmGothicEnums.BodyState BodyState;
// Starts as BS_STAND, not 0: BS_STAND carries flags (interruptable, free hands), so 0 is no body state and
// C_BodyStateContains(npc, BS_STAND) was false for every NPC (and the hero) until a walk action ran.
public VmGothicEnums.BodyState BodyState = VmGothicEnums.BodyState.BsStand;

/// <summary>
/// Npc_IsDead(). Like Gothic, it's the death transition (FightService, loading a dead NPC), not HP <= 0:
Expand Down
10 changes: 6 additions & 4 deletions Assets/Gothic-VR/Scripts/Adapters/Player/VRHeroMovement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ or VmGothicEnums.BodyState.BsWalk or VmGothicEnums.BodyState.BsRun
return;

// Crouched = sneaking.
// Lying or standing up (the VR hero body's fall camera lowers the head) isn't sneaking - an NPC asked "why are you
// sneaking around" while the hero got up.
// Lying or standing up (the VR hero body's fall camera lowers the head) isn't sneaking - an NPC asked "why
// are you sneaking around" while the hero got up.
// Like the engine (OpenGothic Npc::canSneak) only with the sneak
// talent - without it a crouching hero just walks: guards turn to him, Lukis hears him coming.
if (_rig.IsCrouching && !_vrPlayerService.IsHeroBodyDown &&
Expand All @@ -213,8 +213,10 @@ or VmGothicEnums.BodyState.BsWalk or VmGothicEnums.BodyState.BsRun
return;
}

var velocity = _rig.CharacterController.velocity;
var speed = new Vector2(velocity.x, velocity.z).magnitude;
// The rig's own movement this frame, not CharacterController.velocity: that is only the last Move() of the
// frame, and the XRI rig's ground snap (XriRig.SnapToGround) moves straight down after the walk - the
// hero stayed BS_STAND while walking, so NPCs never heard him behind their backs.
var speed = isFirstCheck || Time.deltaTime <= 0f ? 0f : horizontalJump / Time.deltaTime;
var bodyState = speed switch
{
>= _bodyStateRunSpeed => VmGothicEnums.BodyState.BsRun,
Expand Down