Commit a455b99e authored by Petr Mikheev's avatar Petr Mikheev

Fix incorrect speed for creatures, that is caused by...

Fix incorrect speed for creatures, that is caused by !245 (eebbacd8)
parent 355996c2
......@@ -2368,8 +2368,21 @@ void CharacterController::update(float duration, bool animationOnly)
moved.y() *= scale;
// Ensure we're moving in generally the right direction...
if(speed > 0.f && (movement - moved).length2() * 4 > moved.length2())
moved = movement;
if(speed > 0.f)
{
float l = moved.length();
if (std::abs(movement.x() - moved.x()) > std::abs(moved.x()) / 2 ||
std::abs(movement.y() - moved.y()) > std::abs(moved.y()) / 2 ||
std::abs(movement.z() - moved.z()) > std::abs(moved.z()) / 2)
{
moved = movement;
// For some creatures getSpeed doesn't work, so we adjust speed to the animation.
// TODO: Fix Creature::getSpeed.
float newLength = moved.length();
if (newLength > 0 && !cls.isNpc())
moved *= (l / newLength);
}
}
if (mFloatToSurface && cls.isActor() && cls.getCreatureStats(mPtr).isDead() && cls.canSwim(mPtr))
moved.z() = 1.0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment