@@ -1407,7 +1407,7 @@ void AHuman::UpdateCrouching() {
1407
1407
desiredWalkPathYOffset = m_CrouchAmountOverride * m_MaxWalkPathCrouchShift;
1408
1408
} else if (!m_Controller.IsState (BODY_PRONE)) {
1409
1409
if (m_Controller.IsState (BODY_CROUCH)) {
1410
- // Manually crouch fully is the crouch controller state is set
1410
+ // Manually crouch fully when the crouch controller state is set
1411
1411
desiredWalkPathYOffset = m_MaxWalkPathCrouchShift;
1412
1412
} else if (!m_Controller.IsState (BODY_JUMP) && m_pHead) {
1413
1413
// Otherwise figure out auto crouching
@@ -1435,20 +1435,14 @@ void AHuman::UpdateCrouching() {
1435
1435
}
1436
1436
1437
1437
float finalWalkPathYOffset = std::clamp (Lerp (0 .0F , 1 .0F , -m_WalkPathOffset.m_Y , desiredWalkPathYOffset, 0 .3F ), 0 .0F , m_MaxWalkPathCrouchShift);
1438
+ m_CrouchAmount = std::clamp (0 .0F , 1 .0F , finalWalkPathYOffset / m_MaxWalkPathCrouchShift - 0 .5F ); // because it's lerped, it never hits 1 exactly. thus the -0.5F
1438
1439
m_WalkPathOffset.m_Y = -finalWalkPathYOffset;
1439
-
1440
- m_CrouchAmount = desiredWalkPathYOffset / m_MaxWalkPathCrouchShift;
1441
1440
1442
1441
// Adjust our X offset to try to keep our legs under our centre-of-mass
1443
1442
const float ratioBetweenBodyAndHeadToAimFor = 0 .15F ;
1444
1443
Vector headPos = m_pHead ? m_pHead->GetPos () : m_Pos;
1445
1444
float predictedPosition = ((headPos.m_X - m_Pos.m_X ) * ratioBetweenBodyAndHeadToAimFor) + m_Vel.m_X ;
1446
1445
m_WalkPathOffset.m_X = predictedPosition;
1447
- if (m_CrouchAmount > 0 .9F && !m_MoveState == WALK ) {
1448
- // Let the CrouchLimbPath take over here
1449
- m_WalkPathOffset.m_Y = 0 .0F ;
1450
- m_WalkPathOffset.m_X = 0 .0F ;
1451
- }
1452
1446
}
1453
1447
1454
1448
void AHuman::UpdateLimbPathSpeed () {
@@ -1457,9 +1451,13 @@ void AHuman::UpdateLimbPathSpeed() {
1457
1451
m_Paths[BGROUND][m_MoveState].SetTravelSpeedMultiplier (1 .0F );
1458
1452
1459
1453
if (m_MoveState == WALK || m_MoveState == RUN || m_MoveState == CRAWL) {
1454
+ float travelSpeedMultiplier = 1 .0F ;
1455
+
1460
1456
// If crouching, move at reduced speed
1461
- const float crouchSpeedMultiplier = 0 .7F ;
1462
- float travelSpeedMultiplier = Lerp (0 .0F , m_MaxWalkPathCrouchShift, 1 .0F , crouchSpeedMultiplier, -m_WalkPathOffset.m_Y );
1457
+ if (m_MoveState == WALK) {
1458
+ const float crouchSpeedMultiplier = 0 .7F ;
1459
+ travelSpeedMultiplier *= Lerp (0 .0F , 1 .0F , 1 .0F , crouchSpeedMultiplier, m_CrouchAmount);
1460
+ }
1463
1461
1464
1462
// If we're moving slowly horizontally, move at reduced speed (otherwise our legs kick about wildly as we're not yet up to speed)
1465
1463
// Calculate a min multiplier that is based on the total walkpath speed (so a fast walkpath has a smaller multipler). This is so a slow walkpath gets up to speed faster
@@ -1575,7 +1573,7 @@ void AHuman::PreControllerUpdate() {
1575
1573
if (prone) {
1576
1574
// Don't go back to prone if we're already prone, the player has to let go of the crouch button first. If already laying down, just stay put.
1577
1575
m_MoveState = m_ProneState == NOTPRONE ? PRONE : NOMOVE;
1578
- } else if (m_CrouchAmount > 0 . 9F ) {
1576
+ } else if (m_CrouchAmount >= 1 . 0F ) {
1579
1577
// Fully crouching will set the appropriate state so we can use CrouchLimbPath
1580
1578
m_MoveState = CROUCH;
1581
1579
} else {
@@ -1706,13 +1704,15 @@ void AHuman::PreControllerUpdate() {
1706
1704
1707
1705
// TODO: make the delay data driven by both the actor and the device!
1708
1706
//
1709
- if (isSharpAiming && m_Status == STABLE && (m_MoveState == STAND || m_MoveState == PRONE || m_MoveState == NOMOVE || m_MoveState == WALK) && m_Vel.MagnitudeIsLessThan (5 .0F ) && GetEquippedItem ()) {
1707
+ if (isSharpAiming && m_Status == STABLE && m_Vel.MagnitudeIsLessThan (5 .0F ) && GetEquippedItem () &&
1708
+ (m_MoveState == STAND || m_MoveState == CROUCH || m_MoveState == PRONE || m_MoveState == NOMOVE || m_MoveState == WALK)) {
1710
1709
float aimMag = analogAim.GetMagnitude ();
1711
1710
1712
1711
// If aim sharp is being done digitally, then translate to full analog aim mag
1713
1712
if (aimMag < 0 .1F ) {
1714
1713
aimMag = 1 .0F ;
1715
1714
}
1715
+
1716
1716
if (m_MoveState == WALK) {
1717
1717
aimMag *= 0 .3F ;
1718
1718
}
@@ -1991,6 +1991,11 @@ void AHuman::PreControllerUpdate() {
1991
1991
1992
1992
UpdateCrouching ();
1993
1993
1994
+ Vector pathOffset;
1995
+ if (m_MoveState == WALK) {
1996
+ pathOffset = m_WalkPathOffset;
1997
+ }
1998
+
1994
1999
if (m_Status == STABLE && !m_LimbPushForcesAndCollisionsDisabled && m_MoveState != NOMOVE) {
1995
2000
// This exists to support disabling foot collisions if the limbpath has that flag set.
1996
2001
if ((m_pFGFootGroup->GetAtomCount () == 0 && m_BackupFGFootGroup->GetAtomCount () > 0 ) != m_Paths[FGROUND][m_MoveState].FootCollisionsShouldBeDisabled ()) {
@@ -2033,7 +2038,7 @@ void AHuman::PreControllerUpdate() {
2033
2038
m_StrideTimer.Reset ();
2034
2039
}
2035
2040
Vector jointPos = m_Pos + RotateOffset (m_pFGLeg->GetParentOffset ());
2036
- m_ArmClimbing[BGROUND] = !m_pFGFootGroup->PushAsLimb (jointPos, m_Vel, m_WalkAngle[FGROUND], m_Paths[FGROUND][movementPath], deltaTime, &restarted, false , Vector (0 .0F , m_Paths[FGROUND][movementPath].GetLowestY ()), m_WalkPathOffset );
2041
+ m_ArmClimbing[BGROUND] = !m_pFGFootGroup->PushAsLimb (jointPos, m_Vel, m_WalkAngle[FGROUND], m_Paths[FGROUND][movementPath], deltaTime, &restarted, false , Vector (0 .0F , m_Paths[FGROUND][movementPath].GetLowestY ()), pathOffset );
2037
2042
} else {
2038
2043
m_ArmClimbing[BGROUND] = false ;
2039
2044
}
@@ -2044,7 +2049,7 @@ void AHuman::PreControllerUpdate() {
2044
2049
m_StrideTimer.Reset ();
2045
2050
}
2046
2051
Vector jointPos = m_Pos + RotateOffset (m_pBGLeg->GetParentOffset ());
2047
- m_ArmClimbing[FGROUND] = !m_pBGFootGroup->PushAsLimb (jointPos, m_Vel, m_WalkAngle[BGROUND], m_Paths[BGROUND][movementPath], deltaTime, &restarted, false , Vector (0 .0F , m_Paths[BGROUND][movementPath].GetLowestY ()), m_WalkPathOffset );
2052
+ m_ArmClimbing[FGROUND] = !m_pBGFootGroup->PushAsLimb (jointPos, m_Vel, m_WalkAngle[BGROUND], m_Paths[BGROUND][movementPath], deltaTime, &restarted, false , Vector (0 .0F , m_Paths[BGROUND][movementPath].GetLowestY ()), pathOffset );
2048
2053
} else {
2049
2054
if (m_pBGLeg) {
2050
2055
m_pBGFootGroup->FlailAsLimb (m_Pos, RotateOffset (m_pBGLeg->GetParentOffset ()), m_pBGLeg->GetMaxLength (), m_PrevVel, m_AngularVel, m_pBGLeg->GetMass (), deltaTime);
@@ -2208,12 +2213,12 @@ void AHuman::PreControllerUpdate() {
2208
2213
2209
2214
if (m_pFGLeg) {
2210
2215
Vector jointPos = m_Pos.GetFloored () + m_pFGLeg->GetParentOffset ().GetXFlipped (m_HFlipped);
2211
- m_pFGFootGroup->PushAsLimb (jointPos, m_Vel, m_WalkAngle[FGROUND], m_Paths[FGROUND][STAND], deltaTime, nullptr , !m_pBGLeg, Vector (0 .0F , m_Paths[FGROUND][STAND].GetLowestY ()), m_WalkPathOffset );
2216
+ m_pFGFootGroup->PushAsLimb (jointPos, m_Vel, m_WalkAngle[FGROUND], m_Paths[FGROUND][STAND], deltaTime, nullptr , !m_pBGLeg, Vector (0 .0F , m_Paths[FGROUND][STAND].GetLowestY ()), pathOffset );
2212
2217
}
2213
2218
2214
2219
if (m_pBGLeg) {
2215
2220
Vector jointPos = m_Pos.GetFloored () + m_pBGLeg->GetParentOffset ().GetXFlipped (m_HFlipped);
2216
- m_pBGFootGroup->PushAsLimb (jointPos, m_Vel, m_WalkAngle[BGROUND], m_Paths[BGROUND][STAND], deltaTime, nullptr , !m_pFGLeg, Vector (0 .0F , m_Paths[FGROUND][STAND].GetLowestY ()), m_WalkPathOffset );
2221
+ m_pBGFootGroup->PushAsLimb (jointPos, m_Vel, m_WalkAngle[BGROUND], m_Paths[BGROUND][STAND], deltaTime, nullptr , !m_pFGLeg, Vector (0 .0F , m_Paths[FGROUND][STAND].GetLowestY ()), pathOffset );
2217
2222
}
2218
2223
}
2219
2224
}
@@ -2383,7 +2388,7 @@ void AHuman::Update() {
2383
2388
m_SharpAimMaxedOut = true ;
2384
2389
} else if (m_MoveState == WALK) {
2385
2390
maxLength *= 0 .7F ;
2386
- } else if (m_MoveState == CROUCH) {
2391
+ } else if (m_MoveState == CROUCH || m_MoveState == PRONE ) {
2387
2392
// Only when crouching still, otherwise it's WALK
2388
2393
maxLength *= 1 .2F ;
2389
2394
}
@@ -2488,7 +2493,7 @@ void AHuman::Update() {
2488
2493
}
2489
2494
2490
2495
float rotDiff = rot - rotTarget;
2491
- if (std::abs (rotDiff) > c_PI) {
2496
+ if (std::abs (rotDiff) > c_PI * 0 . 75F ) {
2492
2497
// We've h-flipped, so just snap to new orientation
2493
2498
rot = rotTarget;
2494
2499
} else {
0 commit comments