@@ -1721,12 +1721,23 @@ void AHuman::UpdateWalkAngle(AHuman::Layer whichLayer) {
1721
1721
1722
1722
if (m_pHead) {
1723
1723
// Cast a ray above our head to either side to determine whether we need to crouch
1724
- float desiredCrouchHeadRoom = std::floor (m_pHead->GetRadius () + 1 . 5f );
1724
+ float desiredCrouchHeadRoom = std::floor (m_pHead->GetRadius () + 2 . 0f );
1725
1725
float toSide = std::floor (m_pHead->GetRadius () + 3 .0f );
1726
- Vector hitPosLeft = (m_pHead->GetPos () + Vector (-toSide, 0 .0F )).Floor ();
1727
- Vector hitPosRight = (m_pHead->GetPos () + Vector (toSide, 0 .0F )).Floor ();
1728
- g_SceneMan.CastStrengthRay (hitPosLeft, Vector (0 .0F , -desiredCrouchHeadRoom), 10 .0F , hitPosLeft, 0 , g_MaterialGrass);
1729
- g_SceneMan.CastStrengthRay (hitPosRight, Vector (0 .0F , -desiredCrouchHeadRoom), 10 .0F , hitPosRight, 0 , g_MaterialGrass);
1726
+ Vector hitPosLeftStart = (m_pHead->GetPos () + Vector (-toSide, m_SpriteRadius * 0 .5F )).Floor ();
1727
+ Vector hitPosRightStart = (m_pHead->GetPos () + Vector (toSide, m_SpriteRadius * 0 .5F )).Floor ();
1728
+ Vector hitPosLeft, hitPosRight;
1729
+ g_SceneMan.CastStrengthRay (hitPosLeftStart, Vector (0 .0F , -desiredCrouchHeadRoom + m_SpriteRadius * -0 .5F ), 10 .0F , hitPosLeft, 0 , g_MaterialGrass);
1730
+ g_SceneMan.CastStrengthRay (hitPosRightStart, Vector (0 .0F , -desiredCrouchHeadRoom + m_SpriteRadius * -0 .5F ), 10 .0F , hitPosRight, 0 , g_MaterialGrass);
1731
+
1732
+ // Don't do it if we're already hitting, we're probably standing next to a wall
1733
+ if (hitPosLeftStart == hitPosLeft) {
1734
+ hitPosLeft.m_X = 0 .0F ;
1735
+ }
1736
+
1737
+ if (hitPosRightStart == hitPosRight) {
1738
+ hitPosRight.m_X = 0 .0F ;
1739
+ }
1740
+
1730
1741
float headroom = m_pHead->GetPos ().m_Y - std::max (hitPosLeft.m_Y , hitPosRight.m_Y );
1731
1742
float adjust = desiredCrouchHeadRoom - headroom;
1732
1743
float walkPathYOffset = std::clamp (LERP (0 .0F , 1 .0F , -m_WalkPathOffset.m_Y , adjust, 0 .3F ), 0 .0F , m_MaxWalkPathCrouchShift);
0 commit comments