New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS sensors have incorrect orientation #90901
Comments
CC @bruvzg |
Some footage of the problem. First, I show that on Android the gravity arrow always points down in real life. At 16 seconds I show what happens on iOS. sensor_bug_iOS.mp4 |
I think iPhones and iPads might have different base orientations (or maybe it's different on different models), at least on 10 gen. iPad orientation seems to be flipped (not only sensors but orientation in general). |
I'm not able to find any sources on that. What appears to be happening is that the sensors are being rotated the wrong way, which is why the combined rotation makes the gravity vector point straight up. Tbh I don't think a different base orientation can explain it. Wouldn't that result in all the sensors being rotated 90 degrees in Godot? If your iPad produces different results to mine please say. I also tested on an iPhone 13 Pro and it's the same. Here's how Apple defines the device coordinate system from https://developer.apple.com/documentation/coremotion/cmmotionmanager |
Or maybe it's just
|
Seems like there are two issues actually, sensors are incorrect if orientation is controlled by sensor (probably on all devices), and default landscape orientation (if set to fixed) is upside-down (this might be specific for different devices). |
Tested versions
v4.2.1.stable.official [b09f793]
System information
iPadOS 17.4, iPad 9th gen
Issue description
I'm using SCREEN_SENSOR orientation to automatically rotate my app, and sensor vectors (gravity, accelerometer, magnetometer, gyro) don't maintain their orientation relative to the app. This causes them to point in unpredictable directions. Portrait is the only mode that works properly.
The relevant code is here. According to this comment, it was meant to correct their coordinate system by a rotation.
godot/platform/ios/godot_view.mm
Lines 452 to 477 in 9bc49a6
The 3rd case is wrong and should have been (-x,-y,z) in order to rotate 180 degrees in the xy plane. The other 2 cases may have worked at the time, but not anymore.
Steps to reproduce
Export the MRP for iOS. The 3D arrow should point down no matter the orientation.
You can also use the official sensors demo: https://github.com/godotengine/godot-demo-projects/tree/master/mobile/sensors
Minimal reproduction project (MRP)
down-MRP.zip
The text was updated successfully, but these errors were encountered: