Magnetometer or Heading / Compass values on iOS 11?

Hi all,

I’m trying to get values or calculate an equalivalent type value to determine which direction (compass degrees) the user is facing and holding their device towards, so I can orient the game world along their relevant axis.

It seems like this would be fairly simple to do based of the readings from the iphone magenetometer or compass heading, but I can’t seem to find any documentation about accessing or calling those features in UE.

Does anyone have any tips for where to begin approaching this? I figure the answer will stretch beyond blueprints, but I’m curious how involved this could become?

Thanks for the help in advance

Bump, I’m also looking for a way to find the true north


can someone tell me why are there almost no valuable Information about this topic? It seems like nobody can answer this question. I searched for hours and nowhere I can find some answer leading in a possible direction. But I found some links which are interesting, although I´m sure that anybody who wants to know how we can access the Compass will get to this sooner or later. It´s kind of sobering.

User F3NR1S developed a plugin but iOS is still pending:
A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums and

Apple Dev: Apple Developer Documentation and Apple Developer Documentation

Medium article about a compass app: How To Build a Compass App in Swift | by Federico Zanetello | Swiftly Swift | Medium
(But I don´t know how to get access to Swift from Unreal )

How would be the common workflow to execute SwiftCode in Unreal C++?

EDIT: I found a post as a feature request since 4.9 : [Feature Request] Add magnetometer support for mobile platform - Mobile - Unreal Engine Forums

Although a bit late, but just for Completeness,

I found the solution some time ago by ReImplementing the LocationServices - Plugin written by Epic and extended it with the appropriate Objective-C - Code.

You can take a look at “LocationServicesIOSImpl.cpp” from the Engine-Source for example-code.

I didn´t know how Objective-C works before: here is a good way to start:

and for LocationService in common here:

Then we can do something like:

        LocManager = [[CLLocationManager alloc] init];
        LocManager.delegate = self;
        if([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined)
            //we need to request location services
            //[LocManager requestAlwaysAuthorization];
            [LocManager requestWhenInUseAuthorization];
        if([ CLLocationManager headingAvailable])
            LocManager.headingFilter = 5;
            // we also need to deliver LocationUpdates, why? i do not know, but it´s recommended in the apple documentation, maybe it´s a parent service ?
            [LocManager startUpdatingLocation];
            [LocManager startUpdatingHeading];
        if([ CLLocationManager headingAvailable])
            [LocManager stopUpdatingLocation];
            [LocManager stopUpdatingHeading];
            [LocManager release];
            LocManager = nil;
     * Callback from the LocationManager when there is an update to our Heading
    -(void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
        if(newHeading.headingAccuracy < 0)
        //use Heading if its valid
        CLLocationDirection theHeading = ((newHeading.trueHeading > 0) ?
                                          newHeading.trueHeading : newHeading.magneticHeading);
        FHeadingServicesData headingData;
        headingData.MagneticHeading = (float)theHeading;

// and broadcast this to Unreal


Hope this helps.

1 Like

I came back to ask this same question from nearly 3 years later and was so thankful to see your reply. The ue4 community is the best!! this solution works 100%, appreciate it!