Hi to everyone.
I had write a script to rotate a rifle in my app and i have an issue on some devices. The input.gyro.attitude not work properly on my samsung s7 ( on stock rom , lineageos , and some other) and with lg g5. When the main character takes the rifle the rifle rotate but its like trembling.
This is the script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateScript : MonoBehaviour
{
private Gyroscope gyro;
float dx;
float dy;
float x;
float y;
public string scenename;
// Start is called before the first frame update
void Start()
{
gyro = Input.gyro;
if(!gyro.enabled)
{
gyro.enabled = true;
}
if (SystemInfo.supportsGyroscope)
{
//Gyro is available
}
else
{
changemenuscene(scenename);
}
x = Input.gyro.attitude.x;
y = Input.gyro.attitude.y;
}
// Update is called once per frame
void Update()
{
dx = Input.gyro.attitude.x - x;
dy = Input.gyro.attitude.y - y ;
gameObject.transform.Rotate(dy*8, dx*8, 0);
}
public void changemenuscene( string scenename)
{
Application.LoadLevel (scenename);
}
}