title: Stopping the update function in Unity
body: <p>I have some code that when it executes, it pushes a character forward. The issue is that the character never stops moving and continues forever. Is there a way to stop the character from moving after 2 seconds? Here is the code I'm using:</p>
  
  <pre><code> public class meleeAttack : MonoBehaviour
   {
       public int speed = 500;
       Collider storedOther;
       bool isHit = false;
  
       void Start()
       {
       }
  
       void Update()
       {
           if (isHit == true )
           {
               storedOther.GetComponent&lt;Rigidbody&gt;().AddForce(transform.forward * speed);
           }
  
       }
  
  
  
       void OnTriggerStay(Collider other)
       {
           if (other.gameObject.tag == "Player" &amp;&amp; Input.GetKeyUp(KeyCode.F))
           { 
               storedOther = other;
               isHit = true;
           }
       }
  
   }
  </code></pre>
  
  <p>I'm not sure if there's a way to stop the update() function so it stops the character movement.</p>