- Home /
2D game turning
How can I make my character turn around to left and right when I press "a" and "d"
Comment
Best Answer
Answer by ExpiredIndexCard · Jun 03, 2013 at 10:19 PM
if (Input.GetKeyDown("d")){
if(transform.rotation != Quaternion.Euler(0, 180, 0))
transform.rotation = Quaternion.Euler(0, 180, 0);
}
if (Input.GetKeyDown("a")){
if(transform.rotation != Quaternion.Euler(0, 0, 0))
transform.rotation = Quaternion.Euler(0, 0, 0);
}
Try using that. That is the code I used for my game. Also, before posting on here, make sure you have Googled this subject first. If it is not on Google (Most likely not) then post your question right here.
I asked because I did search on google but I couldnt find it, and thank you btw :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613103453im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can Someone help me with a script? (2D) 0 Answers
2D Animation does not start 1 Answer
How can I do a smooth tracking camera, using the animator controller? 1 Answer
left and right 2d walk 1 Answer
cube can turn smooth around 0 Answers