Version: 2022.3
言語: 日本語
public Vector3 rotationRate ;

説明

デバイスのジャイロスコープで測定された回転率を返します

回転率は秒あたりのラジアンで 3 軸それぞれのまわりを回転する速度を表す Vector3 として与えられます。 これはジャイロスコープのハードウェアに報告される値です。 rotationRateUnbiased プロパティーで取得される "バイアス" を除去する処理がされて より正確に測定します。

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.rotationRate.y > shakeSpeed &amp;&amp; !audioSource.isPlaying) audioSource.PlayOneShot(shakeSound); } }