Version: 2017.2

Gyroscope.rotationRateUnbiased

切换到手册
public Vector3 rotationRateUnbiased ;

描述

返回设备陀螺仪测量的无偏差旋转速率。

旋转速率以 Vector3 的形式提供, 表示围绕三个轴中的每一个的旋转速度(以弧度/秒为单位)。该值经去“偏差”处理, 可提供更准确的测量结果。可以使用 rotationRate 属性获取陀螺仪硬件报告的原始值。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public float shakeSpeed; public AudioClip shakeSound; AudioSource audioSource;

void Start() { audioSource = GetComponent<AudioSource>(); }

void Update() { if (Input.gyro.rotationRateUnbiased.y > shakeSpeed &amp;&amp; !audioSource.isPlaying) audioSource.PlayOneShot(shakeSound); } }