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 ;|
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` 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. :)