Does Input.acceleration use gyroscope?
Sorry if the similar topic was already discussed, but any searches including keywords "Input.Acceleration" and "Gyroscope" returns great amount of topics, but I couldn't find anything that is related to my question.
Does 'Input.acceleration' use Gyroscope on mobile devices? Name of the field suggest that it uses only accelerator, but I heard from friend (who is experienced Unity developer, but for Nintendo Switch, and haven't worked on mobile platforms for years) that this is actually using gyroscope underneath. As far as I read on the internet I believe this is using only accelerometer on mobile devices. But on the other hand, when I'm reading about functionality of accelerometer and I compare this to data I get from Input.acceleration I feel like it's returning more info than accelerometer alone can provide, so I am confused.
I would like also to ask is this good idea to publish game focused strictly on accelerometer control. I will implement alternative controls, but it can't be so intuitive and fun to play as those using accelerometer.
Answer by Dipity · Jul 07, 2020 at 07:10 PM
Input.acceleration only uses the accelerometer, you can disable the gyroscope in Unity using Input.gyro.enabled = false
and Input.acceleration will still work.
I have build an App that uses Input.acceleration on smartphones that only have an accelerometer but no gyroscope and it works.
Input.gyro.attitude is the one that uses Accelerometer, Gyroscope and Compass (Magnetometer) for what is called sensor fusion.
Okay, thank you so much for your answer. I hoped the name of this property is accurate and it uses only accelerometer, but some articles about accelerometers really confused me, as it describes it as it's only returning force/acceleration of the phone and from my own experience it is perfect for reading current rotation of the device (I use it in my current project), so I was afraid I could use Gyro as well.
Those articles are right, the accelerometer measures the acceleration/force on the device. It makes use of earth gravity and depending on how you hold your device, earth's gravity will push on the three axes (x, y, z) with different gravitational force. Depending on the rotation that you need for your app, this can be enough.
If you put down your phone flat on a table, Input.acceleration will return ( 0.0, 0.0, -1.0)
. This means that earth's full gravity is pushing down on your phones z-axis. The value 1.0 means its the full earth gravity. Unity already converts the accelerometer raw values into values from -1.0f to 1.0f, so there is some $$anonymous$$ath happening in the background. When you now tilt your phone in different directions, earth's gravity will push with different amount on the three axis of your phone.
Smartphones use the accelerometer for example to detect wether they need to switch to landscape or portrait mode.
It takes a while to get your head around how the sensors work if you never worked with them ;)
Answer by Olpinski · Jul 07, 2020 at 05:01 PM
Maybe anybody has phone without gyroscope and knows how Input.acceleration behaves on those devices.
Your answer
Follow this Question
Related Questions
Motion based Gesture recognition using accelerometer or gyroscope 1 Answer
Getting linear acceleration not using gyroscope on Android 2 Answers
Problem with Android platform 0 Answers
Use quaternion(s) to rotate the accelerator reading 0 Answers
I'm having trouble rotating a game object by dragging screen using touch input 0 Answers