Search Unity

Bug Accelerometer ReadValue inconsistent on iOS

Discussion in 'Input System' started by alanvitek, Apr 25, 2023.

  1. alanvitek

    alanvitek

    Joined:
    Aug 20, 2013
    Posts:
    7
    Hi! I'm using the new Input System, and working on some mechanics using the Accelerometer (specifically deploying on iOS). What I've found is that sometimes the ReadValue for both the Accelerometer and the LinearAccelerometer can be wildly inconsistent.

    In Update(); I am testing with this function:
    Code (CSharp):
    1. Vector3 currentAcceleration = UnityEngine.InputSystem.LinearAccelerationSensor.current.acceleration.ReadValue();
    2. Debug.Log(currentAcceleration);
    In my case, I usually see values like the following when I shake my phone physically with medium force: Vector3(-2.38, -0.05, 5.12).

    However, about 10% of the time I'll see values like this with the same medium force: Vector3(0.0001, 0.002, 0.000).

    I've been unable to determine what would cause this. I have tried both Accelerometer and LinearAccelerometer (think that gravity recalculation might have been the culprit). Both gave similar results.

    Any ideas on why this might be happening?
     
  2. justadropofwater

    justadropofwater

    Joined:
    Aug 22, 2018
    Posts:
    2
    I am seeing this inconsistently on iOS as well. Especially new versions of iOS (looks like 14+). I feel like something has changed here.