Unity – Horizontal and Vertical – Get Axis
Horizontal and Vertical Control – Complete Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #pragma strict function Start () { } var speed : float = 10.0; // to change speed function Update () { var horiz : float = Input.GetAxis( "Horizontal" ); var vert : float = Input.GetAxis( "Vertical" ); // Make it move 10 meters per second instead of 10 meters per frame... horiz *= Time.deltaTime; vert *= Time.deltaTime; transform.Translate(Vector3(horiz*speed,vert*speed,0)); } |