have a command only run for a few seconds unity
StartCoroutine(GoLeft());
 IEnumerator GoLeft()
 {
     // This will wait 1 second like Invoke could do, remove this if you don't need it
     yield return new WaitForSeconds(1);
 
 
     float timePassed = 0;
     while (timePassed < 3)
     {
         // Code to go left here
         timePassed += Time.deltaTime;
 
         yield return null;
     }
 }
