static function GetAxis (axisName : String) : float
Description
Returns the value of the virtual axis identified by axisName.
The value will be in the range -1...1 for keyboard and joystick input.
If the axis is setup to be delta mouse movement, the mouse delta is multiplied by the axis
sensitivity and the range is not -1...1.
var speed : float = 10.0;
var rotationSpeed : float = 100.0;
function Update () {
var translation : float = Input.GetAxis ("Vertical") * speed;
var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
translation *= Time.deltaTime;
rotation *= Time.deltaTime;
transform.Translate (0, 0, translation);
transform.Rotate (0, rotation, 0);
}
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public float speed = 10.0F;
public float rotationSpeed = 100.0F;
void Update() {
float translation = Input.GetAxis("Vertical") * speed;
float rotation = Input.GetAxis("Horizontal") * rotationSpeed;
translation *= Time.deltaTime;
rotation *= Time.deltaTime;
transform.Translate(0, 0, translation);
transform.Rotate(0, rotation, 0);
}
}
import UnityEngine
import System.Collections
class example(MonoBehaviour):
public speed as single = 10.0F
public rotationSpeed as single = 100.0F
def Update():
translation as single = (Input.GetAxis('Vertical') * speed)
rotation as single = (Input.GetAxis('Horizontal') * rotationSpeed)
translation *= Time.deltaTime
rotation *= Time.deltaTime
transform.Translate(0, 0, translation)
transform.Rotate(0, rotation, 0)
var horizontalSpeed : float = 2.0;
var verticalSpeed : float = 2.0;
function Update () {
var h : float = horizontalSpeed * Input.GetAxis ("Mouse X");
var v : float = verticalSpeed * Input.GetAxis ("Mouse Y");
transform.Rotate (v, h, 0);
}
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public float horizontalSpeed = 2.0F;
public float verticalSpeed = 2.0F;
void Update() {
float h = horizontalSpeed * Input.GetAxis("Mouse X");
float v = verticalSpeed * Input.GetAxis("Mouse Y");
transform.Rotate(v, h, 0);
}
}
import UnityEngine
import System.Collections
class example(MonoBehaviour):
public horizontalSpeed as single = 2.0F
public verticalSpeed as single = 2.0F
def Update():
h as single = (horizontalSpeed * Input.GetAxis('Mouse X'))
v as single = (verticalSpeed * Input.GetAxis('Mouse Y'))
transform.Rotate(v, h, 0)