Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

You can run at full speed while crouched #2670

Open
petchema opened this issue Jun 29, 2024 · 3 comments
Open

You can run at full speed while crouched #2670

petchema opened this issue Jun 29, 2024 · 3 comments

Comments

@petchema
Copy link
Collaborator

Describe the issue

If you press the run key while crouched, you'll move at full running speed, same as if you were standing.

To Reproduce

Steps to reproduce the behavior:

  1. Crouch
  2. Walk forward. Notice the speed
  3. Press your run toggle key
  4. Notice the huge speed boost

Expected behavior

In classic, crouching + running seems faster than crouching alone, but much slower than running alone.
I suspect running applies the same speed multiplier whether you're standing or crouched, but I haven't measured to be sure.

Desktop (please complete the following information):

  • OS: Linux
  • Version 1.1.1
@petchema
Copy link
Collaborator Author

petchema commented Jun 29, 2024

PlayerMotor.UpdateSpeed() calls PlayerSpeedChanger.GetBaseSpeed(), then PlayerSpeedChanger.ApplyInputSpeedAdjustment(). The latter totally overrides GetBaseSpeed() computations in the case you're running (l.120):

            if (isRunning)
            {
                speed = RefreshRunSpeed();

P.S.: I just noticed that PlayerSpeedChanger.baseSpeed works as a covert channel between GetBaseSpeed() and GetRunSpeed(), but is only when you're riding, so my analysis still holds when you're crouching? That code is so convoluted...

@petchema
Copy link
Collaborator Author

petchema commented Jul 1, 2024

A simple but cowardly fix would be to consider that when you're crouching you can't be running. Not great, does not match classic, but less surprising than what we have now.

index 0ea93e535..8e7bc9a38 100644
--- a/Assets/Scripts/Game/Player/PlayerSpeedChanger.cs
+++ b/Assets/Scripts/Game/Player/PlayerSpeedChanger.cs
@@ -107,7 +107,7 @@ namespace DaggerfallWorkshop.Game
         {
             if (playerMotor.IsGrounded)
             {
-                isRunning = CanRun() && runningMode;
+                isRunning = CanRun() && runningMode && !playerMotor.IsCrouching;
                 isSneaking = !isRunning && sneakingMode;
             }
             else

@KABoissonneault
Copy link
Collaborator

I'm thinking we might just be able to apply the crouch speed to the run function.

        public float GetRunSpeed()
        {
            Entity.PlayerEntity player = GameManager.Instance.PlayerEntity;
-           float baseRunSpeed = playerMotor.IsRiding ? baseSpeed : (player.Stats.LiveSpeed + dfWalkBase) / classicToUnitySpeedUnitRatio;
+           float baseRunSpeed;
+           if (playerMotor.IsRiding)
+               baseRunSpeed = baseSpeed;
+           else if (playerMotor.IsCrouching && !levitateMotor.IsSwimming)
+               baseRunSpeed = (player.Stats.LiveSpeed + dfCrouchBase) / classicToUnitySpeedUnitRatio;
+           else
+               baseRunSpeed = (player.Stats.LiveSpeed + dfWalkBase) / classicToUnitySpeedUnitRatio;
            return baseRunSpeed * (1.35f + (player.Skills.GetLiveSkillValue(DFCareer.Skills.Running) / 200f));
        }

petchema added a commit to petchema/daggerfall-unity that referenced this issue Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants