- Home /
How do I access the Accelerometer and Gyroscope on my Surface Pro?
I'm trying to make a simple tilt-control game.
I figured that the easiest way to test motion controls as I code them was to work on my Surface Pro, since it's basically a full PC with Accelerometer and Gyro. Problem is, Unity doesn't seem to be recognizing these sensors when I test the game in the editor.
I tried the test code from the script reference on a cube "transform.rotation = Input.gyro.attitude;" And nothing happens. I tried printing the attitude and Input.acceleration and all I get are "(0.0, 0.0, 0.0, 1.0)" and "(0.0, 0.0, 0.0)" respectively, no matter how much I twist and shake the device.
I do currently have my build settings on Windows Store Apps.
So... how can I make Unity recognize my Surface's sensors?
i have the same problem so if u got any news so far id be happy if u or someone else could share those :p
Answer by Jason_N · Mar 07, 2016 at 10:19 AM
I found this. When running in unity editor via the Play button the accelerometer doesn't work. I built it (as a Windows Universal store app, via visual studio), then it worked correctly as a standalone app
@jason_N I expect that the accelerometer works in a windows Uni App (built in visual studio). But how do you get it to work in Unity?
@Jason_N Building it did not work. (running on Surface Pro 5) @CraigGraff I did try Input.gyro.enabled, but it did nothing.
SystemInfo.supportsGyroscope returns false in IDE or EXE :(
I assume you've already realized this, but SystemInfo.supportsGyroscope returning false means that your hardware does not have a gyroscope to read from (or at least doesn't have one that Unity supports).
Building to pc did not work. building to UWP did. The hardware turned out to work, just not in the ID$$anonymous$$ same issue as above. :(
SystemInfo.supportsGyroscope returns true in a build and false in the ide on the same hardware.