Computer Language/Unity
[Unity] Input Arrow Keys
정우섭
2019. 2. 25. 06:37
To make object spin we will use localEulerAngles. localEulerAngles is a way to express Rotation in script which uses the Euler Angles.
If you see the first line of Update() function
You can see 'transform.local.EulerAngles.z', this means object's rotation of z.
And in second line Input.GetAxis("Horizontal"); means if user input right or left arrow key each '+1' or '-1' is inputted. If you want to have inputted up or down arrow key put 'Vertical' instead of 'Horizontal'.
So the value of zRotation will change if user input arrow keys.
And by substituting 'Vector3' in 'localEulerAngles' and 'zRotation' in 'Vector3', user can control the zRotation of the object.