Movement with changing destination
I made a coroutine which uses Vector3.MoveTowards to move from A to B in directly X seconds. Now the problem is if B or current position is changed, script works not good enough. I need object always move towards destination and be there in preset time, not depending from distance changes.
 var timeLeft = fleet.Speed;
 do
 {
    fleet.transform.position = Vector3.MoveTowards(fleet.transform.position, toSectorObj.transform.position, step);
    yield return new WaitForSeconds(Statics.SecondsInterval);
    timeLeft -= Statics.SecondsInterval;
 }
 while (timeLeft > 0);
 
               fleet.Speed is time for object to move from A to B Statics.SecondsInterval is period in which the view of moving is refreshed.
               Comment
              
 
               
                    var timeLeft = fleet.Speed;
      do
      {
         fleet.transform.position = Vector3.$$anonymous$$oveTowards(fleet.transform.position, toSectorObj.transform.position, (fleet.Speed-timeLeft)/timeLeft);
         yield return new WaitForSeconds(Statics.SecondsInterval);
         timeLeft -= Statics.SecondsInterval;
      }
      while (timeLeft > 0);
 
                 Answer by SunnyChow · Jul 05, 2016 at 10:08 AM
 fleet.transform.position = Vector3.Lerp(fleet.transform.position, toSectorObj.transform.position, Statics.SecondsInterval/timeLeft);
 
               haven't really tested it
Your answer