mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Fix diagonal movement being faster than forward movement
This commit is contained in:
parent
fb778f8ecd
commit
767c72e619
@ -863,6 +863,7 @@ void CharacterController::update(float duration)
|
|||||||
bool sneak = cls.getStance(mPtr, MWWorld::Class::Sneak);
|
bool sneak = cls.getStance(mPtr, MWWorld::Class::Sneak);
|
||||||
bool flying = world->isFlying(mPtr);
|
bool flying = world->isFlying(mPtr);
|
||||||
Ogre::Vector3 vec = cls.getMovementVector(mPtr);
|
Ogre::Vector3 vec = cls.getMovementVector(mPtr);
|
||||||
|
vec.normalise();
|
||||||
if(mHitState != CharState_None && mJumpState == JumpState_None)
|
if(mHitState != CharState_None && mJumpState == JumpState_None)
|
||||||
vec = Ogre::Vector3(0.0f);
|
vec = Ogre::Vector3(0.0f);
|
||||||
Ogre::Vector3 rot = cls.getRotationVector(mPtr);
|
Ogre::Vector3 rot = cls.getRotationVector(mPtr);
|
||||||
@ -1119,9 +1120,11 @@ void CharacterController::update(float duration)
|
|||||||
else
|
else
|
||||||
moved = Ogre::Vector3(0.0f);
|
moved = Ogre::Vector3(0.0f);
|
||||||
|
|
||||||
// Ensure we're moving in generally the right direction
|
// Ensure we're moving in generally the right direction...
|
||||||
if(mMovementSpeed > 0.f)
|
if(mMovementSpeed > 0.f)
|
||||||
{
|
{
|
||||||
|
float l = moved.length();
|
||||||
|
|
||||||
if((movement.x < 0.0f && movement.x < moved.x*2.0f) ||
|
if((movement.x < 0.0f && movement.x < moved.x*2.0f) ||
|
||||||
(movement.x > 0.0f && movement.x > moved.x*2.0f))
|
(movement.x > 0.0f && movement.x > moved.x*2.0f))
|
||||||
moved.x = movement.x;
|
moved.x = movement.x;
|
||||||
@ -1131,7 +1134,12 @@ void CharacterController::update(float duration)
|
|||||||
if((movement.z < 0.0f && movement.z < moved.z*2.0f) ||
|
if((movement.z < 0.0f && movement.z < moved.z*2.0f) ||
|
||||||
(movement.z > 0.0f && movement.z > moved.z*2.0f))
|
(movement.z > 0.0f && movement.z > moved.z*2.0f))
|
||||||
moved.z = movement.z;
|
moved.z = movement.z;
|
||||||
|
// but keep the original speed
|
||||||
|
float newLength = moved.length();
|
||||||
|
if (newLength > 0)
|
||||||
|
moved *= (l / newLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update movement
|
// Update movement
|
||||||
if(moved.squaredLength() > 1.0f)
|
if(moved.squaredLength() > 1.0f)
|
||||||
world->queueMovement(mPtr, moved);
|
world->queueMovement(mPtr, moved);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user