1
\$\begingroup\$

How would I rotate an object a certain number of degrees when the left arrow is pressed and then rotate it back to its start when the left arrow is released?

\$\endgroup\$
1
\$\begingroup\$

You may want to look into this and this. Unity makes it really easy.

The scripting reference is your best friend.

Something like the following:

if (Input.GetKeyDown(KeyCode.LeftArrow))
    transform.rotation = Quaternion.Euler(0, 30, 0);
else if (Input.GetKeyUp(KeyCode.LeftArrow))
    transform.rotation = Quaternion.identity;
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.