The old input system can access a phone’s compass using Input.compass, but even though the new InputSystem has been out for several years Unity still hasn’t implemented a compass API. The docs just say “No corresponding API yet.”
This is a massive problem because on Android it’s not possible to use both the old input system and the new one at the same time, if you’re using the new system and attempting to access Input.compass it always returns a heading of 0.
For this project I have to use the new input system, is there any way to access the phone’s compass when using this?
The closest workaround I’ve managed is to try to calculate the compass heading by reading the AttitudeSensor and doing swing twist decomposition along the up vector to get the component of the device’s rotation around the y axis. This doesn’t work well because you get odd influences from the other two axes, the quaternion returned by the attitude sensor itself seems to be inconsistent with the device’s real world orientation. It also seems insane to be juggling quaternions and bodging something together when phones have actual compasses that work accurately.