title: How to decrease value of float over time in C#?
body: <p>I'm building a game in Unity in which my character slides when space key is pressed down. He can only slide when running or sprinting. When player starts sliding, player speed should decrease over some time, meaning he can't slide forever or at the same speed all the time.</p>
  
  <p>I've tried doing another float that has constant value, and reduce player speed with that constant over time passed (Time.deltaTime). However, it only reduced the time once by that value, it needs to do it every second. </p>
  
  <pre><code>float playerSpeed=5.2f;
  
  Update()
  {
      if (Input.GetKey(KeyCode.Space) &amp;&amp; (isRunning == true || isSprinting == 1))
      {
          isSliding = true;         
      }      
      else
      {
          isSliding = false;
      }
  }
  </code></pre>
  
  <p>I expect player speed to decrease from 5.2 to 0 in 2 seconds.</p>