I noticed that on my Samsung S21 (Android 12) device, Input.acceleration sometimes doesn’t work (returns 0). Approximately every second launch of the application is problematic.
Minimizing/maximizing the application usually helps and Input.acceleration starts working.
I tested on an empty project on different versions of Unity 2019.2.12f and 2019.4.37f. The result is the same.
At the same time, on older devices like Nexus 7, Nexus 9, NVIDIA Shield - everything works fine.
I tried updating Samsung S21 from basement version “G991U1UES5BVA6” to “G991U1UES5BVC1”, but that did not solve the problem.
My temporary solution is to use a plugin:
https://github.com/kshoji/Unity-Android-Sensor-Plugin
I use this call:
plugin.Call("startSensorListening", "accelerometer");
And after it, Unity Input.acceleration starts working.
A temporary solution works, but I want to solve this problem without additional plugins.
P.S. Also I found a similar problem from another developer:
Thank you in advance.