# press key, rotate around something

 0 hi, I want to simply rotate object on Z-axis 59 degrees if A-button is clicked, ``````if ( Input.GetKeyDown( "space" ) ) { transform.RotateAround(Vector3.zero, Vector3.right, 150); } `````` but rotate function description says, Eular Angles. when I saw huge I article on Eular angles on wikipedia I hid beneath the table hoping it would go away :S is there a converter or some simpler tutorial explaining eular angles or unity function that uses normal angles ? oh and btw whats key kode for A-button? unity reference said A <-, but this gives me error so i'm stuck with space ;| more ▼ asked Apr 02 '10 at 09:32 PM Hellwalker 35 ● 7 ● 7 ● 13 SisterKy 2.4k ● 33 ● 41 ● 59 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

1 answer: sort voted first
 0 Here: Try this script - it should solve all your problems: ``````var rotation = 1.0; function Update () { if (Input.GetKey ("a")) { rotation += 0.2; transform.Rotate (0,0,rotation * Time.deltaTime); } } `````` The snippet of code above smoothly rotates the cube. If you just want it to 'go', remove the `rotation += 0.2` http://line.To change the rotation speed, modify the `0.2` number. Hope this helps! Also, here's a link to the input page for all the keys in Unity. P.S. Hiding under beds is much safer, and you should always ask all your Unity-related questions here. :) more ▼ answered Apr 02 '10 at 09:43 PM e.bonneville 5.7k ● 100 ● 116 ● 165 works like a charm, thx man :D Apr 02 '10 at 10:25 PM Hellwalker Your code was framerate-dependent, and also defining `rotation` as an int means that adding 0.2 to it would cause it to never increase, so I fixed it. Apr 02 '10 at 11:11 PM Eric5h5 @Eric5h5: Thanks a lot. I didn't think of that - I'm still a beginner in the logic of coding. Although I know the API, I keep forgetting those minute details that make things go. Apr 03 '10 at 12:00 AM e.bonneville add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Topics:

x727
x87
x50

asked: Apr 02 '10 at 09:32 PM

Seen: 5149 times

Last Updated: Nov 27 '12 at 01:50 PM