- Home /

# orienting player in one direction

So I'm facinf a little annoying problem since a while and I don't know how to solve it. So basically I want that when I press A or D the player facing left and right, so the rotation value should be y=270 (left) and y=90(right). and i wrote this code:

` private void GetInput() { direction = Vector2.zero; Quaternion target = Quaternion.Euler(0, 180, 0); transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * 50f); if (Input.GetKey(KeyCode.W)) { direction += Vector2.up; facing = "up"; target = Quaternion.Euler(0, 0, 0); transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * 50f); } if (Input.GetKey(KeyCode.S)) { direction += Vector2.down; facing = "down"; target = Quaternion.Euler(0, 180, 0); transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * 50f); } if (Input.GetKey(KeyCode.D)) { direction += Vector2.left; facing = "left"; transform.rotation = Quaternion.Euler(0,270,0); transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * 50f); } if (Input.GetKey(KeyCode.A)) { direction += Vector2.right; facing = "right"; transform.rotation = Quaternion.Euler(0, 90, 0); transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * 50f); } }`

the problem is, it not work. is not turning left and right, but is working ud and down.

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

Orientation axis to rotation 0 Answers

Moving and rolling a cube 0 Answers

How to set a limit for my player rotation ? 0 Answers

Device orientation problems android 1 Answer