Path planning is an important research field in robotics, and it is also a key technology for realizing automatic navigation of aircraft. It is of great significance both in theory and in application. The task of planning trajectories for an aircraft has received considerable attention in the research literature. Most of the work assumes that the threat to the aircraft is static; less attention has been paid to the problem of the changing environment. However, the threat from the weather when the UAV is flying in the air is always changing. This paper introduces an improved BFS algorithm, which can find the best safe path when the threat is always changing.