This paper proposes a novel relay algorithm to optimize the communication throughput of unmanned aerial vehicle (UAV) mobile relay formations while considering the challenges posed by obstacle avoidance, channel complexity, high dynamics of UAVs, and real-time mission requirements.