This is handled with things called Animation Editors and Animation Blueprints. These allow you to use things like Blendspaces, State Machines, Animgraphs, Montages, and all kinds of other stuff that involve animation and the logic tied to those animations. This is among the densest, most complex topics in UE4 in my opinion, but once you wrap your head around the basics you can achieve what you’re trying to do without too much trouble.