[Feature Request] Add magnetometer support for mobile platform

I mean TYPE_MAGNETIC_FIELD in Android Sensors API.

It would be helpful in homebrew realisations for Google Cardboard support.

If UE developers confirm that this feature is need but there is no time frame, I could contribute by myself for Android branch.

Yes ! Would be very helpful !
Any idea on how to handle this ?

Go for it :slight_smile: Even if it won’t be added at least you will have solution for your game

I have an idea. There is files

  • LaunchAndroid.cpp
  • AndroidInputImterface.cpp

In it there is method QueueMotionData. And obvious few other files must be changed according to add to EKeys a Magnetometer key properly. Soon I’ll try to compile Engine for the first time, so don’t expect very fast results. Although I don’t plan to give up on any obstacle. Stay tuned =)

this is exactly what i’m trying to figure out now for VR button, have you made any progress on this? Thanks!

Sorry. Testing few compass apps I figured out that magnetometer won’t help much in my app. So this feature is at the end of my checklist. Sorry again.

I found UE4.15 has “Mobile Location Services” and “Optional Mobile Features Blueprint Library” as blueprint plugins, so now I can get the location (longitude and latitude) via blueprint.
However, it seems that we don’t have a blueprint for accessing the magnetometer.
Although there are “Gravity”, “Rotation Rate” and “Tilt” input blueprints, magnetometer is essential for calculating the exact device orientation.
For example, when we put a mobile device on a desk, we can know the device is put horizontally via “Gravity” vector, but we can never know the exact roll rotation of the device if we rotate the device on the desk without magnetometer.

Is there any way to get the direction vector of North Pole? Blueprint implementation is best, but if not so, I would like to know the exact code to get it on iPhone or iPad.


I’m looking an answer for the same question,hope there is any upcoming updates

Hi Kakushi_52,

did you found meanwhile a solution for accessing the magnetometer ?

No, unfortunately still not…