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

pull/3019/head
Petr Mikheev 4 years ago
parent 8050882baf
commit 9ec6fce446

@ -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.

@ -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
---------------------

@ -328,6 +328,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

Loading…
Cancel
Save