ソースを参照

Zeros external velocity if we're still on the ground after running a player movement update cycle. This prevents sliding on landing if we give players horizontal impulses from props like jumppads

Signed-off-by: kberg-amzn <[email protected]>
kberg-amzn 2 年 前
コミット
a7d0007ff4

+ 8 - 0
Gem/Code/Source/Components/NetworkPlayerMovementComponent.cpp

@@ -281,6 +281,14 @@ namespace MultiplayerSample
         GetNetworkAnimationComponentController()->ModifyActiveAnimStates().SetBit(
             aznumeric_cast<uint32_t>(CharacterAnimState::Falling), isFalling);
 
+        // If we're still on the ground, then zero out our velocity from external forces
+        // This prevents us from sliding along the ground after we land
+        PhysX::CharacterGameplayRequestBus::EventResult(onGround, GetEntityId(), &PhysX::CharacterGameplayRequestBus::Events::IsOnGround);
+        if (onGround)
+        {
+            SetVelocityFromExternalSources(AZ::Vector3::CreateZero());
+        }
+
         // At the end, track whether or not we were on the ground for this input so we can compare states when processing the next input.
         SetWasOnGround(onGround);
     }