To overcome the limitations of a single USV in task execution, this paper investigates the issues of cooperative motion and obstacle avoidance for USV swarm. The leader-follower control approach is chosen as the strategy for coordinating the formation of multiple USVs. Kinematic and kinetic controllers are designed using sliding mode control, with a saturation function replacing the sign function to avoid chattering. The validity of the kinematic and kinetic controllers is demonstrated using the Lyapunov stability theorem. To tackle the problem of goal reachability when obstacles are nearby in the artificial potential field method for obstacle avoidance, the repulsive potential field function is modified by including the distance factor between the USV and the target point. To address the problem of local minimum, the simulated annealing algorithm is incorporated into the traditional artificial potential field method. Multi-condition simulation experiments are conducted using MATLAB. The experimental results demonstrate that multiple USVs can form a formation in a short time and maintain the formation while navigating, exhibiting high robustness. Furthermore, they are able to effectively navigate through complex marine environments, successfully avoiding obstacles and ultimately reaching their target destination.