【发布时间】:2017-05-12 20:26:08
【问题描述】:
我正在制作一个 360 度视频播放器,相机放置在球体的中心,并且我已经在相机中实现了陀螺仪,它正在工作,但是当我四处走动时会发生奇怪的抖动,看起来像是即使手机静止,也会出现某种延迟。 屏幕方向锁定为横向。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Gyro : MonoBehaviour {
private Gyroscope gyro;
private bool gyroSupported;
private Quaternion rotFix;
void Start()
{
gyroSupported = SystemInfo.supportsGyroscope;
GameObject camParent = new GameObject("camParent");
camParent.transform.position = transform.position;
transform.parent = camParent.transform;
if (gyroSupported)
{
gyro = Input.gyro;
gyro.enabled = true;
camParent.transform.rotation = Quaternion.Euler(90f, 180f, 0f);
rotFix = new Quaternion(0, 0, 1, 0);
}
}
void Update()
{
this.transform.Rotate(-Input.gyro.rotationRateUnbiased.x, -Input.gyro.rotationRateUnbiased.y, -Input.gyro.rotationRateUnbiased.z);
}
}
【问题讨论】:
-
您的手机品牌和型号是什么?你也测试过其他手机吗?
-
@Hristo 我在 Iphone 5c 和三星 s5 上测试过,都存在同样的问题
标签: c# android unity3d gyroscope