Version: 2020.1
言語: 日本語
public Vector3 gravity ;

説明

デバイスの参照フレームでの正確な重力加速度のベクトルを返します

using UnityEngine;

public class Example : MonoBehaviour { float movementScale;

void Update() { // A "spirit level" - the dot product of the gravity and the Y axis (ie, Vector3.up) // is a measure of how far the device is from level on that axis (it will be zero // if the device is perfectly level). This value can be used to position an object // to act as the "bubble". Vector3 pos = transform.position; pos.y = Vector3.Dot(Input.gyro.gravity, Vector3.up) * movementScale; transform.position = pos; } }