- Home /
rotate an object with keyboard
I read this question http://answers.unity3d.com/questions/794119/how-to-rotate-an-object-around-a-fixed-point-so-it.html and i got the idea but i want to do the same thing but with keyboard how can i do that i try a lot of things put not worked
Comment
Best Answer
Answer by Dragate · Oct 06, 2017 at 11:21 AM
public Vector3 point; //position of the point you want to rotate around
void Update () {
if (Input.GetKey(KeyCode.A)){
transform.RotateAround(point, Vector3.up, 20 * Time.deltaTime);
} else if (Input.GetKey(KeyCode.D))
transform.RotateAround(point, -Vector3.up, 20 * Time.deltaTime);
}
}