The discovery of shared behavioral processes across phyla is a significant step in the establishment of a comparative study of behavior. We use immobility as an origin and reference for the measurement of fly locomotor behavior; speed, walking direction and trunk orientation as the degrees of freedom shaping this behavior; and cocaine as the parameter inducing progressive transitions in and out of immobility. We characterize and quantify the generative rules that shape Drosophila locomotor behavior, bringing about a gradual buildup of kinematic degrees of freedom during the transition from immobility to normal behavior, and the opposite narrowing down into immobility. Transitions into immobility unfold via sequential enhancement and then elimination of translation, curvature and finally rotation. Transitions out of immobility unfold by progressive addition of these degrees of freedom in the opposite order. The same generative rules have been found in vertebrate locomotor behavior in several contexts (pharmacological manipulations, ontogeny, social interactions) involving transitions in-and-out of immobility. Recent claims for deep homology between arthropod central complex and vertebrate basal ganglia provide an opportunity to examine whether the rules we report also share common descent. Our approach prompts the discovery of behavioral homologies, contributing to the elusive problem of behavioral evolution.