In this paper, dual RRT optimization is proposed to solve the formation shape generation problem for a large number of MUVs. Since large numbers of MUVs are prone to collision during formation shape generation, this paper considers the use of path planning algorithms to solve the collision avoidance problem. Additionally, RRT as a commonly used path planning algorithm has non-optimal solutions and strong randomness. Therefore, this paper proposes a dual RRT optimization to improve the drawbacks of RRT, which is applicable to the formation shape generation of MUVs. First, an initial global path can be obtained quickly by taking advantage of RRT-connect. After that, RRT* is used to optimize the initial global path locally. After finding the section that needs to be optimized, RRT* performs a new path search on the section and replaces the original path. Due to its asymptotic optimality, the path obtained by RRT* is shorter and smoother than the initial path. Finally, the algorithm can further optimize the path results by introducing a path evaluation function to determine the results of multiple runs. The experimental results show that the dual RRT operation optimization can greatly reduce the running time while avoiding obstacles and obtaining better path results than the RRT* algorithm. Moreover, multiple runs still ensure stable path results. The formation shape generation of MUVs can be completed in the shortest time using dual RRT optimization.