Question by
gesunonviama · Feb 14, 2016 at 11:04 PM ·
camerascript.camera-movementcamera rotate
Camera movement with arrow keys?
Hello, im searching a script who can move the camera with arrow keys, im searching it for days, can someone help me? Thanks very much!
Comment
Best Answer
Answer by bcaloe · Feb 15, 2016 at 07:17 AM
Unity has the arrows keys set as default inputs for Horizontal and Vertical axis.
You should be able to receive those input by adding these lines in your script.
void Update () {
inputX = Input.GetAxis ("Horizontal");
inputZ = Input.GetAxis ("Vertical");
if (inputX != 0)
rotate ();
if (inputZ != 0)
move ();
}
void rotate(){
transform.Rotate (new Vector3 (0f, inputX * Time.deltaTime, 0f));
}
void move(){
transform.position += transform.forward * inputZ * Time.deltaTime;
}
Hope you got the idea : )
why whenever I use the horizontal and vertical thing it wont work (not just on this but on all of them)