@@ -853,13 +853,20 @@ var groundedState
853853 //print("old vel: " + currentVelocity + " new vel: " + newVelocity + " move dir: " + characterMoveVelocity + " Dir dot: " + dirDot + " currentSpeed: " + currentSpeed + " grounded: " + grounded + " canJump: " + canJump + " didJump: " + didJump);
854854 }
855855
856+ var underMaxSpeed = velMagnitude < ( moveData . useAccelerationMovement
857+ ? currentSpeed
858+ : Mathf . Max ( moveData . sprintSpeed , currentSpeed ) + 1 ) ;
859+
860+ if ( underMaxSpeed ) {
861+ currentMoveState . airborneFromImpulse = false ;
862+ }
863+
864+
856865 if ( currentMoveState . isFlying ) {
857866 newVelocity . x = md . moveDir . x * currentSpeed ;
858867 newVelocity . z = md . moveDir . z * currentSpeed ;
859- } else if ( ! isImpulsing && ! currentMoveState . airborneFromImpulse && //Not impulsing AND under our max speed
860- velMagnitude < ( moveData . useAccelerationMovement
861- ? currentSpeed
862- : Mathf . Max ( moveData . sprintSpeed , currentSpeed ) + 1 ) ) {
868+ } else if ( ! isImpulsing && ! currentMoveState . airborneFromImpulse && underMaxSpeed ) {
869+ //Not impulsing AND under our max speed
863870 if ( moveData . useAccelerationMovement ) {
864871 newVelocity += Vector3 . ClampMagnitude ( characterMoveVelocity , currentSpeed - velMagnitude ) ;
865872 } else {
@@ -876,10 +883,9 @@ var groundedState
876883 }
877884 } else {
878885 //Moving faster than max speed or using acceleration mode
879- newVelocity += normalizedMoveDir * ( dirDot * dirDot / 2 ) *
880- ( groundedState == CharacterState . Sprinting
881- ? moveData . sprintAccelerationForce
882- : moveData . accelerationForce ) ;
886+ newVelocity += normalizedMoveDir * ( dirDot * dirDot / 2 * ( groundedState == CharacterState . Sprinting
887+ ? moveData . sprintAccelerationForce
888+ : moveData . accelerationForce ) ) ;
883889 }
884890
885891 //print("isreplay: " + replaying + " didHitForward: " + didHitForward + " moveVec: " + characterMoveVector + " colliderDot: " + colliderDot + " for: " + forwardHit.collider?.gameObject.name + " point: " + forwardHit.point);
0 commit comments