Skip to content

Commit 8182cf2

Browse files
committed
Made Lua set crouch amount lerp instead of snap
1 parent 7478bb7 commit 8182cf2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Entities/AHuman.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,7 +1727,7 @@ void AHuman::UpdateWalkAngle(AHuman::Layer whichLayer) {
17271727

17281728
void AHuman::UpdateCrouching() {
17291729
if (!m_Controller.IsState(BODY_JUMP) && m_pHead) {
1730-
float walkPathYOffset = 0.0F;
1730+
float desiredWalkPathYOffset = 0.0F;
17311731
if (m_CrouchAmountOverride == -1.0F) {
17321732
// Cast a ray above our head to either side to determine whether we need to crouch
17331733
float desiredCrouchHeadRoom = std::floor(m_pHead->GetRadius() + 2.0f);
@@ -1748,13 +1748,13 @@ void AHuman::UpdateCrouching() {
17481748
}
17491749

17501750
float headroom = m_pHead->GetPos().m_Y - std::max(hitPos.m_Y, hitPosPredicted.m_Y);
1751-
float adjust = desiredCrouchHeadRoom - headroom;
1752-
walkPathYOffset = std::clamp(LERP(0.0F, 1.0F, -m_WalkPathOffset.m_Y, adjust, 0.3F), 0.0F, m_MaxWalkPathCrouchShift);
1751+
desiredWalkPathYOffset = desiredCrouchHeadRoom - headroom;
17531752
} else {
1754-
walkPathYOffset = m_CrouchAmountOverride * m_MaxWalkPathCrouchShift;
1753+
desiredWalkPathYOffset = m_CrouchAmountOverride * m_MaxWalkPathCrouchShift;
17551754
}
17561755

1757-
m_WalkPathOffset.m_Y = -walkPathYOffset;
1756+
float finalWalkPathYOffset = std::clamp(LERP(0.0F, 1.0F, -m_WalkPathOffset.m_Y, desiredWalkPathYOffset, 0.3F), 0.0F, m_MaxWalkPathCrouchShift);
1757+
m_WalkPathOffset.m_Y = -finalWalkPathYOffset;
17581758

17591759
// If crouching, move at reduced speed
17601760
const float crouchSpeedMultiplier = 0.5F;

0 commit comments

Comments
 (0)