if (Input.GetButton(“Sprint”)) speed = 200f;
if (Input.GetButton(“Aim”)) speed = 50f;
else speed = 100;
Sprint doesn’t change the value of speed, but Aim does.
However, when I replace Sprint’s command with a Debug.Log, it works as expected.
I’ve also tried this:
if (Input.GetButton("Sprint"))
{
Debug.Log("1");
speed = 200;
Debug.Log("2");
}
“1” and “2” are displayed in the console, but the value of speed isn’t changed - and again, Aim does change it.
So, Sprint works - or should work, as evidenced by the Debug.Log - but can’t alter speed, even though the practically identical Aim-statement can.
What’s the cause of this Schrödinger’s code? How do I fix this?
Thank you in advance.