Question by
whatisitstudios_unity · Nov 12, 2020 at 08:56 PM ·
fpsspeedfpscontroller
How to make speed go slower?
Hi, I'm working on a game, and I would like the player to go slower when you press shift (I have set up shift as crouch in the input manager). I tried this code and it didn't work, can somone tell me what I'm doing wrong?
void Update()
{
if (Input.GetButtonDown("Crouch"))
{
playerSpeed = 2.5f;
}
else
{
playerSpeed = 5f;
}
}
Comment
Answer by LordDAVidus · Nov 13, 2020 at 12:04 PM
GetButtonDown is only true the frame you started to press the key. Use GetButton instead. It's true every frame the key is pressed.
if (Input.GetButton("Crouch"))
{
playerSpeed = 2.5f;
}
Your answer
Follow this Question
Related Questions
which is the best software to make an fps 0 Answers
Increase FPS 0 Answers
C# FPS Speed Boost 0 Answers
Vertical Velocity for fps 0 Answers
How do I make the shoot button move the screen too? 0 Answers