Answer the question
In order to leave comments, you need to log in
How to get rid of the rotation code repetition?
My character rotates depending on which buttons are pressed. Because of this, there is a repetition of the same thing:
if(Input.GetKey(KeyCode.D) && Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.S))
{
angle = Quaternion.Euler(0, 45, 0);
}
else if(Input.GetKey(KeyCode.W) && Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D) && !Input.GetKey(KeyCode.S))
{
angle = Quaternion.Euler(0, -45, 0);
}
// и так далее
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question