Player Rotation/Movement

Hello. What I want to do is if the left or right button is pressed, I want the player to rotate around itself, and if the forward or backward button is pressed, I want the player to move. With this method below the rotation is working correctly but if I rotate the player 180 degrees, the forward/backward buttons work the exact opposite way. Or when rotated in some other random degree, the forward/backward doesn’t work in the correct direction. Is the problem related to the transform.RotateAround()?

 void Movement()
    {
        if (moveLeft)
        {
            transform.RotateAround(player.position, Vector3.down, 90 * Time.deltaTime);
        }
        else if (moveRight)
        {
            transform.RotateAround(player.position, Vector3.up, 90 * Time.deltaTime);
        }
        else
        {
            horizontalMove = 0;
        }

        if (moveForward)
        {
            verticalMove = speed;
        }
        else if (moveBackward)
        {
            verticalMove = -speed;
        }
        else
        {
            verticalMove = 0;
        }
    }

In the Update(), the Movement() is called, and in the FixedUpdate, velocity is set:
player.velocity = new Vector3(horizontalMove*Time.deltaTime, player.velocity.y, verticalMove*Time.deltaTime);

When you call

player.velocity = new Vector3(horizontalMove*Time.deltaTime, player.velocity.y, verticalMove*Time.deltaTime);

It is setting the player’s velocity in World Coordinates, but you actually want to set the player’s velocity relative to the rotation of the player. Do something like this instead

Vector3 forwardVel = player.transform.forward * verticalMove;
Vector3 sideVel = player.transform.right * horizontalMove;
Vector3 upVel = new Vector3(0, player.velocity.y, 0);

player.velocity = fowardVel + sideVel + upVel;

Also, important side note, if you are setting a velocity you generally shouldn’t use Time.deltaTime. This should only be used when you are changing a position incrementally or applying a constant acceleration over time.