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); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961