mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-04 05:09:40 +00:00
Merge pull request #2397 from Capostrophic/gamepad
Analogue movement fixes
This commit is contained in:
commit
f9143decc9
2 changed files with 9 additions and 8 deletions
|
@ -703,7 +703,7 @@ namespace MWInput
|
|||
mOverencumberedMessageDelay = 0.f;
|
||||
}
|
||||
|
||||
if (mAlwaysRunActive || isRunning)
|
||||
if ((mAlwaysRunActive && !mJoystickLastUsed) || isRunning)
|
||||
mPlayer->setRunState(!actionIsActive(A_Run));
|
||||
else
|
||||
mPlayer->setRunState(actionIsActive(A_Run));
|
||||
|
|
|
@ -1979,24 +1979,24 @@ void CharacterController::update(float duration, bool animationOnly)
|
|||
osg::Vec3f rot = cls.getRotationVector(mPtr);
|
||||
|
||||
speed = cls.getSpeed(mPtr);
|
||||
float analogueMult = 1.f;
|
||||
if(isPlayer)
|
||||
{
|
||||
// Joystick anologue movement.
|
||||
// Joystick analogue movement.
|
||||
float xAxis = std::abs(cls.getMovementSettings(mPtr).mPosition[0]);
|
||||
float yAxis = std::abs(cls.getMovementSettings(mPtr).mPosition[1]);
|
||||
float analogueMovement = ((xAxis > yAxis) ? xAxis : yAxis);
|
||||
analogueMult = ((xAxis > yAxis) ? xAxis : yAxis);
|
||||
|
||||
// If Strafing, our max speed is slower so multiply by X axis instead.
|
||||
if(std::abs(vec.x()/2.0f) > std::abs(vec.y()))
|
||||
analogueMovement = xAxis;
|
||||
analogueMult = xAxis;
|
||||
|
||||
// Due to the half way split between walking/running, we multiply speed by 2 while walking, unless a keyboard was used.
|
||||
if(!isrunning && !sneak && !flying && analogueMovement <= 0.5f)
|
||||
speed *= 2;
|
||||
|
||||
speed *= (analogueMovement);
|
||||
if(!isrunning && !sneak && !flying && analogueMult <= 0.5f)
|
||||
analogueMult *= 2.f;
|
||||
}
|
||||
|
||||
speed *= analogueMult;
|
||||
vec.x() *= speed;
|
||||
vec.y() *= speed;
|
||||
|
||||
|
@ -2063,6 +2063,7 @@ void CharacterController::update(float duration, bool animationOnly)
|
|||
}
|
||||
}
|
||||
fatigueLoss *= duration;
|
||||
fatigueLoss *= analogueMult;
|
||||
DynamicStat<float> fatigue = cls.getCreatureStats(mPtr).getFatigue();
|
||||
|
||||
if (!godmode)
|
||||
|
|
Loading…
Reference in a new issue