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