diff --git a/Assets/Gothic-Core/Scripts/Adapters/Properties/NpcProperties.cs b/Assets/Gothic-Core/Scripts/Adapters/Properties/NpcProperties.cs index 31d2f4a7c..c6a587fe0 100644 --- a/Assets/Gothic-Core/Scripts/Adapters/Properties/NpcProperties.cs +++ b/Assets/Gothic-Core/Scripts/Adapters/Properties/NpcProperties.cs @@ -121,7 +121,9 @@ public bool AreAllQueued(Func 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; /// /// Npc_IsDead(). Like Gothic, it's the death transition (FightService, loading a dead NPC), not HP <= 0: diff --git a/Assets/Gothic-VR/Scripts/Adapters/Player/VRHeroMovement.cs b/Assets/Gothic-VR/Scripts/Adapters/Player/VRHeroMovement.cs index dde896027..4672d4360 100644 --- a/Assets/Gothic-VR/Scripts/Adapters/Player/VRHeroMovement.cs +++ b/Assets/Gothic-VR/Scripts/Adapters/Player/VRHeroMovement.cs @@ -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 && @@ -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,