This paper explores the challenges of multiple unmanned surface vehicles (USVs) to maintain formation and effectively avoid obstacles in unknown and complex marine environments. To this end, a novel formation control and obstacle avoidance strategy based on the virtual structure and artificial potential field (VSAPF) approach is proposed in this paper. The core concept is to apply the improved dynamic window approach (IDWA) to the formation control algorithm at the virtual reference unmanned surface Vessel(VRUSV).We name this algorithm IDWA-VSAPF.First, the DWA algorithm is improved. This includes a revision of the velocity window and three existing evaluation functions, while a new evaluation function is introduced. This new function expands the sampling range of velocity and improves the scoring of favorable trajectories. In addition, adaptive weighting coefficients are employed to enhance the USV's target navigation and global search capabilities in unknown environments and to effectively mitigate the local minima problem. The proposed approach is applicable to USV formations with various virtual structures. Finally, extensive simulations demonstrate the effectiveness of the IDWA-VSAPF algorithm. The results show that the approach achieves stable formation maintenance, flexible obstacle avoidance and transformation. In addition, the improved DWA greatly improves the passage efficiency and global search capability of USVs in unknown environments.