- Home /
Question by
craftercis · Aug 28, 2018 at 01:25 PM ·
mobilegyroscope360-degreesgyroshaking
Shaking screen using the gyroscope attitude
Hey,
I have an problem when I use Gyro attitude. When I move my telephone and then hold it still the screen is shaking for 3/4 seconds and then stop it.
How can I fix this?
Code:
if (Input.gyro.enabled)
{
transform.rotation = Quaternion.Euler(90.0f, 0.0f, 0.0f) * new Quaternion(Input.gyro.attitude.x, Input.gyro.attitude.y, -Input.gyro.attitude.z, -Input.gyro.attitude.w);
}
Video: Video of the problem The big shake is me and the little is my problem
Comment
Answer by phxcs · Oct 14, 2019 at 11:35 AM
I'm having the same issue...
I just fixed this issue, this is my script attached to the camera:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GyroController : $$anonymous$$onoBehaviour
{
GameObject camParent;
// Start is called before the first frame update
void Start()
{
camParent = new GameObject("CamParent");
camParent.transform.position = this.transform.position;
this.transform.parent = camParent.transform;
Input.gyro.enabled = true;
}
// Update is called once per frame
void Update()
{
camParent.transform.Rotate(0, -Input.gyro.rotationRateUnbiased.y, 0);
this.transform.Rotate(-Input.gyro.rotationRateUnbiased.x, 0, 0);
}
}