How to make player only go in 4 directions?

At the moments i am using theese. But i dont wanna go diagonally, only go in 4 directions. How to do that?

Userplayer.cs

	public override void TurnUpdate ()
	{
		if (Vector3.Distance(moveDestination, transform.position) > 0.1f) {
			transform.position += (moveDestination - transform.position).normalized * moveSpeed * Time.deltaTime;
			
			if (Vector3.Distance(moveDestination, transform.position) <= 0.1f) {
				transform.position = moveDestination;
				GameManager.instance.nextTurn();
			}
		}
		
		base.TurnUpdate ();
	}
}

GameManager.cs

// Update is called once per frame
void Update () {
	
	players[currentPlayerIndex].TurnUpdate();
}

public void nextTurn() {
	if (currentPlayerIndex + 1 < players.Count) {
		currentPlayerIndex++;
	} else {
		currentPlayerIndex = 0;
	}
}

public void moveCurrentPlayer(Tile destTile) {
	players[currentPlayerIndex].moveDestination = destTile.transform.position + 0.95f * Vector3.up;
}

Player.cs

using UnityEngine;
using System.Collections;

public class Player : MonoBehaviour {
	
	public Vector3 moveDestination;
	public float moveSpeed = 10.0f;
	
	void Awake () {
		moveDestination = transform.position;
	}
	
	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		
	}
	
	public virtual void TurnUpdate () {
		
	}
}

hmmmmm… not sure how you are controlling the character, but if you are using vertical and horizontal controls you can always put in a boolian to lock out the use of the other.

for example you would create 2 boolians “lockHorizontal” and “lockVertical” which are both set to true. When the horizontal button is pressed the “lockVertical” will get set to false and vice-versa. You can only move the player if the button is pressed and the co-responding boolian for that direction is set to true. Once the button is release (on ButtonUp) the opposing boolian would get set back to true.

So, when one axis is pressed it will set the other axis’s boolian to false, Locking it out. this would mean you can only move left or right or up or down, never diagonal.

You could use something similar the following method. This assumes your four directions are on the x and y plane.

private Vector3 RemoveDiagonal (Vector3 inputVector){
    float X = inputVector.x;
    float Y = inputVector.y
    if (X*X > Y*Y){
        return new Vector3 (X,0,0);
    } else {
        return new Vector3 (0,Y,0);
    }
}