unity3d Input System Read Accelerometer Sensor (Basic)


Example

Input.acceleration is used to read the accelerometer sensor. It returns Vector3 as a result which contains x,y and z axis values in 3D space.

void Update()
{
    Vector3 acclerometerValue = rawAccelValue();
    Debug.Log("X: " + acclerometerValue.x + "  Y: " + acclerometerValue.y + "  Z: " + acclerometerValue.z);
}

Vector3 rawAccelValue()
{
    return Input.acceleration;
}