- 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

Rotate object around another object C# 2 Answers

The vision of a camera (displayed as a 3D Cone) needs to rotate towards the player 1 Answer

How do I make sure a object faces a certain direction? 1 Answer

find the angle to rotate the gun to face mouse point with its barrel 1 Answer

how can i substract one axis by 180? 2 Answers