Add gravity to CharacterController::AddMovement for proper movement when using Root Motion
This commit is contained in:
@@ -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())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user