Snap, does anyone remember these mechanics? I do and I loved them. For those who are not familiar with them, check out the modern way to How To Make a Cardboard Box Marble Labyrinth Game Video. Awesome.
As you can imagine, we’re not cutting cardboards but use this game’s idea in a Blue Print to rotate an Actor (the plane).
Yeah, you get the idea.
We’re working with the Gyroscope via Unreal Engine’s high-level implementation: Tilt.
We actually only have to take care of two things:
- Translate these inputs to a Rotator relative to your Actor
- Understand Tilt-Input
Find your Axes
So, in order to get this straight, you have to look at your Actor itself and around which axes (yeah, that’s apparently the plural of axis) you want to rotate. In my case, it was only the X and the Y. The following image shows you why. We do not want to rotate the board in our hands, just tilt it. Btw. thanks UE4 for reflecting my gizmo. Really .. helps, I guess 🙂
Understanding the Tilt Vector
The Tilt Motion Input returns a vector, which is understandable as a Rotator, consisting of:
The incoming values are relative, pretty much the same as the Rotation Rate, which we’ve already used in this article. We only have to figure which axis belongs to which input value. To demonstrate this, I’ve added a picture. If you’re laying down your phone on a table like this, the Z axis is represented by the rotation you’d apply to set it as portrait towards you. Eventually we’re not going to use it.
Note: There has to be a re-routing from the incoming Z axis to UE4’s Rotator Y axis. I have yet to find out why, but it simply seems like a mistitled pin connection in the BP Editor.
Since the incoming values are ranged -1 to 1, we’re multiplying them by 10 to get a little more response from them. This mainly depends on your scene size, camera position, etc. For me, 10 felt good.
Finally, I figured I had to multiply the Pitch by a negative value, because .. yeah, I don’t know, people aren’t sure about what the default orientation of the iPhone itself is, I guess. Check this if you’re interested, otherwise, this Mulitpy Vector node is the one to touch if things are mirrored.