Movement on one axis at a time, X and Y.

I want to make my character move only in the X and Y axis, which I have done. But I want the player to only move on one axis at a time, i.e. if you’re moving up and hit/hold the D key it will stop your forward progression and move you to the Right. I’m using GetAxis currently for my movement. Also when the key is released I don’t want the player to slide like he does currently.

float moo= Input.GetAxis (“Vertical”);
float meow= Input.GetAxis (“Horizontal”);
if(moo!=0){
meow=0;
}
transform.position+=new Vector3(meow,moo,0);