Task optimization in the presence of signal-dependent noise (TOPS) has been proposed as a general framework for planning goal-directed movements. Within this framework, the motor command is assumed to be corrupted by signal-dependent noise, which leads to a distribution of possible movements. A task can then be equated with optimizing some function of the statistics of this distribution. We found the optimal trajectory for obstacle avoidance by minimizing the mean-squared error at the end of the movement while keeping the probability of collision with the obstacle below a fixed limit. The optimal paths accurately predicted the empirical trajectories. This demonstrates that controlling the statistics of movements in the presence of signal-dependent noise may be a fundamental and unifying principle of goal-directed movements.