- Home /
Question by
IamMaxim · Aug 14, 2015 at 03:32 PM ·
accelerometeraccelerationsensor
Input.acceleration uses gravity sensor
I'm using this script from official unity tutorials:
using UnityEngine; using System.Collections;
public class CameraScript : MonoBehaviour {
public float speed = 1;
private Vector3 dir;
void Update () {
dir.x = -Input.acceleration.y;
dir.z = Input.acceleration.x;
if (dir.sqrMagnitude > 1)
dir.Normalize();
dir *= Time.deltaTime;
transform.Translate(dir * speed);
}
}
but it uses my gravity sensor(It's not hardware problem, I used CPU-Z on my phone to detect that, my phone has accelerometer and gravity sensor). Object just moves in one direction, if I rotate phone it changes direction. Do you have any ideas?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220611235852im_/https://answers.unity.com/themes/thub/images/avi.jpg)