Move only in 4 direction

Hi everybody! First sorry about my bad english ^^

i’m doing a pixel 2D game, and i want to change my direction’s system

i’m using a simple script to move in any direction, and now i want to modify him to move only on 4 directions(up, down, left, right) but i failed to understand how :confused:

here my script :

if (CrossPlatformInputManager.GetAxisRaw("Horizontal") > 0.5f || CrossPlatformInputManager.GetAxisRaw("Horizontal") < -0.5f)
                    {

                        myRigidoby.velocity = new Vector2(CrossPlatformInputManager.GetAxisRaw("Horizontal") * currentMoveSpeed, myRigidoby.velocity.y);
                        playerMoving = true;
                        lastMove = new Vector2(CrossPlatformInputManager.GetAxisRaw("Horizontal"), 0f);
                    PlayerPrefs.SetFloat("PlayerX", this.transform.position.x);
                    PlayerPrefs.SetFloat("PlayerY", this.transform.position.y);
                }
                    else
                    {
                        myRigidoby.velocity = new Vector2(0f, myRigidoby.velocity.y);
                    }
                    if (CrossPlatformInputManager.GetAxisRaw("Vertical") > 0.5f || CrossPlatformInputManager.GetAxisRaw("Vertical") < -0.5f)
                    {

                        myRigidoby.velocity = new Vector2(myRigidoby.velocity.x, CrossPlatformInputManager.GetAxisRaw("Vertical") * currentMoveSpeed);
                        playerMoving = true;
                        lastMove = new Vector2(0f, CrossPlatformInputManager.GetAxisRaw("Vertical"));
                    PlayerPrefs.SetFloat("PlayerX", this.transform.position.x);
                    PlayerPrefs.SetFloat("PlayerY", this.transform.position.y);
                }
                    else
                    {
                        myRigidoby.velocity = new Vector2(myRigidoby.velocity.x, 0f);
                    }

so if someone can help me i really apreciate - !

Have a good night!

Just use else if so only one direction can be used at a time.

        myRigidoby.velocity = Vector2.zero;

        if (Mathf.Abs(CrossPlatformInputManager.GetAxisRaw("Horizontal")) > 0.5f)
        {
            //
        }
        else if (Mathf.Abs(CrossPlatformInputManager.GetAxisRaw("Vertical")) > 0.5f)
        {
            //
        }