-1
我試圖開發一款可以檢測汽車加速,制動和轉彎速度的應用程序。我需要檢測設備加速。這個加速度是高還是低?像Google Play上的flo應用一樣。Unity3D - 如何從Input.gyro獲得最高加速值
我正在使用陀螺儀,我需要從陀螺儀獲得用戶加速度(x,y,z軸)的最高值。 x,y和z的值正在改變每一幀。我需要獲得這個3軸的最高價值供以後使用。
現在我當前的代碼看起來像這樣
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class NewBehaviourScript : MonoBehaviour
{
public Text x, y, z;
void Start()
{
Input.gyro.enabled = true;
}
void Update()
{
x.text = Mathf.Abs(Input.gyro.userAcceleration.x).ToString();
y.text = Mathf.Abs(Input.gyro.userAcceleration.y).ToString();
z.text = Mathf.Abs(Input.gyro.userAcceleration.z).ToString();
}
}
感謝所有幫助
你的問題很混亂....你想檢查哪個軸大於3個?解釋更多關於你想要做什麼...... – Programmer
不,我想獲得每個軸的最高值 –
獲得x,y,z的最高值......這是沒有意義的。如果您確實需要幫助,請修改您的問題,然後添加您的最高價值以及您要存檔的內容。 – Programmer