Unmanned aerial vehicles (UAVs) provide efficient and flexible means for maritime emergency rescue, with path planning being a critical technology in this context. Most existing unmanned device research focuses on land-based path planning in two-dimensional planes, which fails to fully leverage the aerial advantages of UAVs and does not accurately describe offshore environments. Therefore, this paper establishes a three-dimensional offshore environmental model. The UAV’s path in this environment is achieved through a novel swarm intelligence algorithm, which is based on the coati optimization algorithm (COA). New strategies are introduced to address potential issues within the COA, thereby solving the problem of UAV path planning in complex offshore environments. The proposed OCLCOA introduces a dynamic opposition-based search to address the population separation problem in the COA and incorporates a covariance search strategy to enhance its exploitation capabilities. To simulate the actual environment as closely as possible, the environmental model established in this paper considers three environmental factors: offshore flight-restricted area, island terrain, and sea winds. A corresponding cost function is designed to evaluate the path length and path deflection and quantify the impact of these three environmental factors on the UAV. Experimental results verify that the proposed algorithm effectively solves the UAV path planning problem in offshore environments.