For decades, the origin of the concentric ring pattern of bacterial swarming colonies has puzzled microbiologists. Thanks to _in situ_ and real time infrared microspectroscopy and the brilliance of the infrared beam at SOLEIL synchrotron, we demonstrate here that _Proteus mirabilis_ swarming is paced by a periodic variation of the water activity at colony's edge. This periodic variation originates a phase transition within the extracellular matrix water H bond network which switches on and off the exopolysaccharides viscoelasticity and, consequently, the ability of bacterial cells to swarm. A dynamic behaviour emerges from the global properties of the multicellular entity which here relies on the ability of the bacterial cells to tune exoproducts synthesis in order to undergo sharp transitions above/below a given water activity threshold