Portrait mode only affects some mobile devices' gyroscope rotation values

Bug:

While writing a script to determine the direction that my phone is pointing in, I noticed that UserInputService:GetDeviceRotation() returns different values for my OnePlus 6 (Android device) if the PlayerGui.ScreenOrientation value is not landscape.

However, upon testing on my iPhone SE (iOS device), I found that UserInputService:GetDeviceRotation() returns the same expected values, regardless of the ScreenOrientation.

So if I point my devices in the same direction in portrait mode, the two devices would give me two completely different values, as one of them is still under the assumption that it is in landscape mode. If I do the same while my devices are in landscape mode, they both return the same expected values.

Because of this inconsistency, I now have to force both devices’ orientation as landscape to ensure that I’m given the values I actually need.


Steps to reproduce:

  1. Go to StarterGui properties and set ScreenOrientation to “Portrait”.
  2. Create a LocalScript that outputs a part of the device’s rotation. (example at the bottom of the post)
  3. Run the script on two devices that use the ScreenOrientation differently and note how the output are different to what is expected. My assumption would be the difference is Android and iOS, having been tested on one of each.
  4. Repeat, but set ScreenOrientation to an option containing “Landscape”.

Example:

local UserInputService = game:GetService("UserInputService")

while wait(1) do
    local _, Rotation = UserInputService:GetDeviceRotation()
    print(Rotation.LookVector.Y)
    -- Pointing device upwards, considering orientation, causes value to be 1 on my Android device.
    -- Pointing device upwards, while holding it landscape, causes value to be 1 on my iOS device, regardless of chosen orientation.
    -- Pointing device upwards in portrait mode on my iOS device does not cause the value to be 1.
end
6 Likes