title: How to create a 'sprint' ability in a 2d game
body: <p>I'm trying to create an ability of sprinting in 2d Unity (C#) that has an energy bar so it can't be used endlessly. What am I missing?</p>
  
  <p>I've tried making sprint a function and call it when the X key was pressed. Tried to multiply the position of it but I got a blinking ability over a short distance. </p>
  
  <pre><code>\\ this is my movement script, other variables we're declared earlier in the code
  
  void Update() { 
          Vector2 mi = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
          mv = mi.normalized * speed;
      }
  
      private void FixedUpdate() {
          rb.MovePosition(rb.position + mv * Time.fixedDeltaTime);
      }
  </code></pre>
  
  <p>I expect the code to make the player go twice the normal speed when the X key is pressed but it can only be used when the energy hasn't ran out.</p>