Browse Source

Fixed issue in demo where character 'jumps' when stopping movement on a slope

Fixes #1139
Jorrit Rouwe 1 year ago
parent
commit
da4656acb6
1 changed files with 2 additions and 1 deletions
  1. 2 1
      Samples/Tests/Character/CharacterTest.cpp

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

@@ -94,7 +94,8 @@ 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;
-		desired_velocity.SetY(current_velocity.GetY());
+		if (!desired_velocity.IsNearZero() || !mCharacter->IsSupported())
+			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;
 
 
 		// Jump
 		// Jump