Add gravity to CharacterController::AddMovement for proper movement when using Root Motion

This commit is contained in:
Wojtek Figat
2024-10-30 00:01:54 +01:00
parent c1bd42ff7e
commit 4de9e9d918

View File

@@ -261,7 +261,13 @@ void CharacterController::UpdateBounds()
void CharacterController::AddMovement(const Vector3& translation, const Quaternion& rotation) void CharacterController::AddMovement(const Vector3& translation, const Quaternion& rotation)
{ {
Move(translation); Vector3 displacement = translation;
// Apply gravity
const float deltaTime = Time::GetCurrentSafe()->DeltaTime.GetTotalSeconds();
displacement += GetPhysicsScene()->GetGravity() * deltaTime;
Move(displacement);
if (!rotation.IsIdentity()) if (!rotation.IsIdentity())
{ {