The mean-field dynamics of a collection of stochastic agents evolving under local and nonlocal interactions in one dimension is studied via analytically solvable models. The nonlocal interactions between agents result from (a) a finite extension of the agents interaction range and (b) a barycentric modulation of the interaction strength. Our modeling framework is based on a discrete two-velocity Boltzmann dynamics which can be analytically discussed. Depending on the span and the modulation of the interaction range, we analytically observe a transition from a purely diffusive regime without definite pattern to a flocking evolution represented by a solitary wave traveling with constant velocity.