Play animation while moving vertically or horizontally

How do i make a character play an animation while they are moving vertically or horizontally?

https://unity3d.com/learn/tutorials