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!