Merge pull request #2397 from Capostrophic/gamepad

Analogue movement fixes
pull/541/head
Andrei Kortunov 6 years ago committed by GitHub
commit f9143decc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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…
Cancel
Save