返回介绍

Input.GetAxisRaw 获取原始轴

发布于 2019-12-18 15:37:53 字数 1266 浏览 1001 评论 0 收藏 0

JavaScript => public static function GetAxisRaw(axisName: string): float;
C# => public static float GetAxisRaw(string axisName);

Description 描述

Returns the value of the virtual axis identified by axisName with no smoothing filtering applied.

通过axisName名称返回一个不使用平滑滤波器的虚拟轴值。

The value will be in the range -1…1 for keyboard and joystick input. Since input is not smoothed, keyboard input will always be either -1, 0 or 1. This is useful if you want to do all smoothing of keyboard input processing yourself.

键盘和摇杆取值范围在-1…1之间,此输入没有使用平滑。键盘输入必然会是-1、0或1。这一点在你想自己处理键盘平滑输入时很实用。

JavaScript:

	function Update () {
		var speed : float = Input.GetAxisRaw("Horizontal") * Time.deltaTime;
		transform.Rotate (0, speed, 0);	
	}

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    void Update() {
        float speed = Input.GetAxisRaw("Horizontal") * Time.deltaTime;
        transform.Rotate(0, speed, 0);
    }
}

Input

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文