How do I restrict my character's movement to one axis?

https://www.youtube.com/watch?v=94p9WzvzxBg (1:04)
This video showcases the sliding in Ultrakill pretty well.