title: How slowly move object in function with help Vector2.Lerp in unity?
body: <p>How can i stay in a function for a certain amount of time? I know about coroutines, so i should call coroutines every times for simple things? For example: when i press the key, at that time call function, which slowly move the character.
  The function fires instantly, that's why it doesn't work</p>
  <pre><code>void Update()
  {
      RaycastHit2D hitPlayer = Physics2D.Raycast(_tr.position,new Vector2(-1,0), _distance, LayerMask.GetMask(&quot;Player&quot;));
      if (hitPlayer.collider != null &amp;&amp; Input.GetKeyDown(KeyCode.Space))
      {
          MovingToBox(hitPlayer);
      }
  }
  
  private void MovingToBox(RaycastHit2D hitPlayer)
  {
      
  }
  </code></pre>