- Home /
Question by
flamangoalberto2 · Oct 27, 2020 at 11:55 AM ·
2dbooleanproblem during runtimefalsesprinting
Why is my boolean false when it's clearly not?
So here are my codes:
Sprint
if (sprint && m_Sprint) { m_OldSpeed = m_Player.Speed; m_SprintSpeed = m_Player.Speed; m_SprintSpeed += 25; m_Player.Speed = m_SprintSpeed; } else if (!sprint && m_Sprint) { m_Player.Speed = m_OldSpeed; print("It's false!"); }
Execution
if (Input.GetKeyDown(KeyCode.LeftShift)) { sprint = true; } else if (Input.GetKeyUp(KeyCode.LeftShift)) { sprint = false; }
So how does this make any sense when the if statement is supposed to be called when the boolean is false, but it's not false. Here is why:
It's 200 because the boolean is true, but the Player Speed is the same since it's false: Even the console says it's false:
So is this a Unity bug or am I doing something wrong?
screenshot-2020-10-26-191014.png
(1.3 kB)
screenshot-2020-10-26-191410.png
(1.6 kB)
Comment