How to set x and y coordinates instead of vector3.right?

Here is my code to make the 2d player move left and right when the arrow keys are pressed.

if (Input.GetKeyDown(KeyCode.LeftArrow))
transform.Translate(-Vector2.right * distance);
else if (Input.GetKeyDown(KeyCode.RightArrow))
transform.Translate(Vector2.right * distance);

I need the character to move left and right but at a 45 degree angle, so was just wondering if there’s a way to use x and y coordinates instead of .right? Thanks!

If you want the movement to be diagonal, just use the same “direction” number in both X and Y of the vector2:

float direction = 0;
if (Input.GetKeyDown(KeyCode.LeftArrow)) { direction -= 1; }
if (Input.GetKeyDown(KeyCode.RightArrow)) { direction +1; }
transform.Translate(new Vector2(direction, direction) * distance);