Fixes #1209: Tarhiel never falls

There are a few pitfalls with this code:
 - Gravity is only considered when applying queued movement. Therefore, make sure to queue some movement every frame. (Could be refactored in the future?)
 - The character controller never detects being in free fall (!World::isOnGround) unless movement has been applied.
actorid
scrawl 11 years ago
parent 688e03a9d2
commit 394284d0f8

@ -1245,12 +1245,8 @@ void CharacterController::update(float duration)
else //avoid z-rotating for knockdown
world->rotateObject(mPtr, rot.x, rot.y, 0.0f, true);
// always control actual movement by animation unless this:
// FIXME: actor falling/landing should be controlled by physics engine
if(mMovementAnimVelocity == 0.0f && (vec.length() > 0.0f || mJumpState != JumpState_None))
{
if (mMovementAnimVelocity == 0)
world->queueMovement(mPtr, vec);
}
}
movement = vec;
@ -1290,7 +1286,7 @@ void CharacterController::update(float duration)
}
// Update movement
if(moved.squaredLength() > 1.0f)
if(mMovementAnimVelocity > 0)
world->queueMovement(mPtr, moved);
}
mSkipAnim = false;

Loading…
Cancel
Save