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.