Input.GetAxis()

来源:互联网 发布:java类的调用 编辑:程序博客网 时间:2024/05/16 11:47

语法

public static float GetAxis(string axisName);

用法描述

Returns the value of the virtual axis identified by axisName.

  • The value will be in the range -1…1 for keyboard and joystick input.

键盘输入&joystick输入

  • 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.

鼠标输入

This is frame-rate independent; you do not need to be concerned about varying frame-rates when using this value.

与帧率无关

示例代码

using UnityEngine;using System.Collections;public class ExampleClass : 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);    }}
原创粉丝点击