Using Magnetometer data to rotate a Camera or Actors (iOS)

One of the most impressive features I like about AR is the estimation of your device’s Point Of View. I always liked to have a direct feedback of real-world rotation/acceleration within your application, e.g. the tilt-feature in iOS homescreen is a subtle, but effective way to achieve that.


Speaking of tilt, I quickly figured I need this real-world impact in UE4 projects. Imagine you’re standing in your living room, which you’ve also modelled and deployed with Unreal Engine and if you turn yourself in the room, your app will follow, thus always showing in the same direction as you. You could realise a painting-assistant, work with Line Tracing to estimate furniture, etc.

Overall setup

Super simple. Considering the data from the Magnetometer, the UDK offers us quite some high level implementation of Apple’s Core Motion, namely the Motion State.

Motion Events inside UE 4.17

For now, we only need the Rotation Rate, so head to your Palette and go for it. My level is observed by a camera, so we’re using this as an Actor, but it works with anything.

We’ll keep the original camera’s rotation in a custom Float, apply a new offset to it (the X-vector of the Rotation Data) and set the camera’s relative rotation to this new value whenever the iPhone dispatches a change.


To shorten things, here’s the most basic Blueprint I could think of. We’re only using the Yaw to translate the rotation.

Rotate an actor based on your real-world rotation.

Have a nice build!

One thought to “Using Magnetometer data to rotate a Camera or Actors (iOS)”

Leave a Reply

Your email address will not be published. Required fields are marked *