- Home /
Question by
Sash00 · Apr 26, 2015 at 08:27 PM ·
rotationaccelerometergyroscopecompassheadlookcontroller
Rotation script for Android using acceleration
Hey,
I am trying to create camera movement mechanic that will reciprocate the users head movement with tilting the device - something like the effect you get when using google cardboard with an android device - I am new to unity I just would like to know how to set up the camera rotation to match the users head movement using the acceleration and or compass inputs for android
This is what I have been trying but I cant seem to get it to do what I need it to do.
public Quaternion Gyro; // Use this for initialization void Start () {
}
// Update is called once per frame
void Update () {
Gyro.x = (-(Input.acceleration.x));
Gyro.y = (-(Input.acceleration.y));
Gyro.z = ((Input.acceleration.z));
Gyro.w = 0;
transform.rotation = Gyro;
Thanks!
Comment