@@ -1722,23 +1722,23 @@ void AHuman::UpdateWalkAngle(AHuman::Layer whichLayer) {
1722
1722
if (m_pHead) {
1723
1723
// Cast a ray above our head to either side to determine whether we need to crouch
1724
1724
float desiredCrouchHeadRoom = std::floor (m_pHead->GetRadius () + 2 .0f );
1725
- float toSide = std::floor (m_pHead->GetRadius () + 3 . 0f );
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);
1725
+ float toPredicted = std::floor (m_Vel. m_X * m_pHead->GetRadius ()); // Check where we'll be a second from now
1726
+ Vector hitPosStart = (m_pHead->GetPos () + Vector (0 . 0F , m_SpriteRadius * 0 .5F )).Floor ();
1727
+ Vector hitPosPredictedStart = (m_pHead->GetPos () + Vector (toPredicted , m_SpriteRadius * 0 .5F )).Floor ();
1728
+ Vector hitPos, hitPosPredicted ;
1729
+ g_SceneMan.CastStrengthRay (hitPosStart , Vector (0 .0F , -desiredCrouchHeadRoom + m_SpriteRadius * -0 .5F ), 10 .0F , hitPos , 0 , g_MaterialGrass);
1730
+ g_SceneMan.CastStrengthRay (hitPosPredictedStart , Vector (0 .0F , -desiredCrouchHeadRoom + m_SpriteRadius * -0 .5F ), 10 .0F , hitPosPredicted , 0 , g_MaterialGrass);
1731
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 ;
1732
+ // Don't do it if we're already hitting, we're probably in a weird spot
1733
+ if (hitPosStart == hitPos ) {
1734
+ hitPos .m_X = 0 .0F ;
1735
1735
}
1736
1736
1737
- if (hitPosRightStart == hitPosRight ) {
1738
- hitPosRight .m_X = 0 .0F ;
1737
+ if (hitPosPredictedStart == hitPosPredicted ) {
1738
+ hitPosPredicted .m_X = 0 .0F ;
1739
1739
}
1740
1740
1741
- float headroom = m_pHead->GetPos ().m_Y - std::max (hitPosLeft .m_Y , hitPosRight .m_Y );
1741
+ float headroom = m_pHead->GetPos ().m_Y - std::max (hitPos .m_Y , hitPosPredicted .m_Y );
1742
1742
float adjust = desiredCrouchHeadRoom - headroom;
1743
1743
float walkPathYOffset = std::clamp (LERP (0 .0F , 1 .0F , -m_WalkPathOffset.m_Y , adjust, 0 .3F ), 0 .0F , m_MaxWalkPathCrouchShift);
1744
1744
m_WalkPathOffset.m_Y = -walkPathYOffset;
0 commit comments