Optimal control of time-dependent targets