Summary Tasks such as reaching out toward a distant target require adaptive and goal-oriented muscle-activity patterns. The CNS likely composes such patterns from behavioral subunits. How this coordination is done is a central issue in neural motor control [ 1]. Here, we present a novel paradigm, which allows us to address this question in Drosophila with neurogenetic tools. Freely walking flies are faced with a chasm in their way. Whether they initiate gap-crossing behavior at all and how vigorously they try to reach the other side of the gap depend on a visual estimate of the gap width. By interfering with various putative distance-measuring mechanisms, we found that flies chiefly use the vertical edges on the targeted side to distill the gap width from the parallax motion generated during the approach. At gaps of surmountable width, flies combine and successively improve three behavioral adaptations to maximize the front-leg reach. Each leg pair contributes in a different manner. A screen for climbing mutants yielded lines with defects in the control of climbing initiation and others with specific impairments of particular behavioral adaptations while climbing. The fact that the adaptations can be impaired separately unveils them as distinct subunits.