- Home /
Question by
johnsci911 · May 08, 2017 at 01:05 PM ·
accelerometergyroscope5.3
Mobile tilting using Input.acceleration.z is not tilting properly on the right rotation
I have an issue about tilting the board using the phones gyro or accelerometer. When I put my mobile phone on the table it tilts slightly. I want the board to be completely flat and not moving when the phone is on the table
Here is my code:
void FixedUpdate()
{
float tiltAroundZ = Input.acceleration.x * -tiltAngle;
float tiltAroundX = Input.acceleration.z * -tiltAngle;
Quaternion target = Quaternion.Euler(tiltAroundX, 0, tiltAroundZ);
transform.rotation = Quaternion.Slerp(transform.rotation, target,
Time.deltaTime * 10f);
}
}
Thank you for your help in advance
Comment