Browse Source

CharacterTest: Prevent bunny hopping on elevator going down

Jorrit Rouwe 1 year ago
parent
commit
fa0222c44e
1 changed files with 1 additions and 1 deletions
  1. 1 1
      Samples/Tests/Character/CharacterTest.cpp

+ 1 - 1
Samples/Tests/Character/CharacterTest.cpp

@@ -94,7 +94,7 @@ void CharacterTest::HandleInput(Vec3Arg inMovementDirection, bool inJump, bool i
 		// Update velocity
 		// Update velocity
 		Vec3 current_velocity = mCharacter->GetLinearVelocity();
 		Vec3 current_velocity = mCharacter->GetLinearVelocity();
 		Vec3 desired_velocity = sCharacterSpeed * movement_direction;
 		Vec3 desired_velocity = sCharacterSpeed * movement_direction;
-		if (!desired_velocity.IsNearZero() || !mCharacter->IsSupported())
+		if (!desired_velocity.IsNearZero() || current_velocity.GetY() < 0.0f || !mCharacter->IsSupported())
 			desired_velocity.SetY(current_velocity.GetY());
 			desired_velocity.SetY(current_velocity.GetY());
 		Vec3 new_velocity = 0.75f * current_velocity + 0.25f * desired_velocity;
 		Vec3 new_velocity = 0.75f * current_velocity + 0.25f * desired_velocity;