1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 15:29:55 +00:00

Merge branch 'configurable_turning_delay' into 'master'

Makes the delay of turning while run configurable (part of "smooth movement")

See merge request OpenMW/openmw!349
This commit is contained in:
psi29a 2020-10-17 20:21:02 +00:00
commit f513ee1f1d
3 changed files with 16 additions and 1 deletions

View file

@ -1966,6 +1966,7 @@ void CharacterController::update(float duration, bool animationOnly)
static const bool smoothMovement = Settings::Manager::getBool("smooth movement", "Game");
if (smoothMovement && !isFirstPersonPlayer)
{
static const float playerTurningCoef = 1.0 / std::max(0.01f, Settings::Manager::getFloat("smooth movement player turning delay", "Game"));
float angle = mPtr.getRefData().getPosition().rot[2];
osg::Vec2f targetSpeed = Misc::rotateVec2f(osg::Vec2f(vec.x(), vec.y()), -angle) * movementSettings.mSpeedFactor;
osg::Vec2f delta = targetSpeed - mSmoothedSpeed;
@ -1975,7 +1976,7 @@ void CharacterController::update(float duration, bool animationOnly)
float maxDelta;
if (std::abs(speedDelta) < deltaLen / 2)
// Turning is smooth for player and less smooth for NPCs (otherwise NPC can miss a path point).
maxDelta = duration * (isPlayer ? 3.f : 6.f);
maxDelta = duration * (isPlayer ? playerTurningCoef : 6.f);
else if (isPlayer && speedDelta < -deltaLen / 2)
// As soon as controls are released, mwinput switches player from running to walking.
// So stopping should be instant for player, otherwise it causes a small twitch.

View file

@ -344,6 +344,17 @@ Recommended to use with "turn to movement direction" enabled.
This setting can be controlled in Advanced tab of the launcher.
smooth movement player turning delay
------------------------------------
:Type: floating point
:Range: >= 0.01
:Default: 0.333
Max delay of turning (in seconds) if player drastically changes direction on the run. Makes sense only if "smooth movement" is enabled.
This setting can only be configured by editing the settings configuration file.
NPCs avoid collisions
---------------------

View file

@ -340,6 +340,9 @@ turn to movement direction = false
# Makes all movements of NPCs and player more smooth.
smooth movement = false
# Max delay of turning (in seconds) if player drastically changes direction on the run.
smooth movement player turning delay = 0.333
# All actors avoid collisions with other actors.
NPCs avoid collisions = false