I have this code to my sprint function but when i run and the time is out i don’t know how restart the time and run again the function to sprint. I need to know how to put a loop in this code.
float sprintTime;
if (Input.GetKey(KeyCode.LeftShift))
{
sprintTime += 1 / (1 / Time.deltaTime);
}
if (Input.GetKeyDown(KeyCode.LeftShift) && sprintTime <= 2f)
{
walkSpeed = 5.5f;
}
if (Input.GetKeyUp(KeyCode.LeftShift) || sprintTime > 2f)
{
walkSpeed = 2.5f;
}