# How to set up tilt input axis mappings for mobile devices?

**URL:** <https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750>\
**Category:** World Creation\
**Tags:** gravity, tilt, unreal-engine, acceleration, Physics, Android, question\
**Created:** [April 26, 2014, 8:47pm UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750 "2014-04-26T20:47:03Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_b204e58e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b204e58e1](https://forums.unrealengine.com/u/anonymous_user_b204e58e1)\
**Post date:** [April 26, 2014, 8:47pm UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750/1 "2014-04-26T20:47:03Z")

</div>

I tried using Tilt, Gravity, Acceleration, and Rotation Rate as axis mappings in my input settings, but they don’t do anything when I test my game on my Nexus 5. What am I missing? How do I use my device’s rotation as input?

---

<div class="post-metadata">

**Author:** ![Marc\_Audy](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/marc_audy/32/710746_2.png) [@Marc\_Audy](https://forums.unrealengine.com/u/Marc_Audy)\
**Post date:** [April 26, 2014, 9:21pm UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750/2 "2014-04-26T21:21:41Z")

</div>

Can you give me a little details on how you tried to set them up?

If you were trying to bind them directly to the Axis Mappings then yeah, those aren’t going to work at the moment as the current Axis Mappings are single float value axes. I am planning on getting the vector axes bindable through the input components, hopefully for 4.2, but no promises.

Currently you should be able to use the PlayerController function GetInputMotionState to get the current values of each of the device motion vectors. If that is not working for you please let me know so we can take a closer look at it.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b204e58e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b204e58e1](https://forums.unrealengine.com/u/anonymous_user_b204e58e1)\
**Post date:** [April 27, 2014, 11:48pm UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750/3 "2014-04-27T23:48:13Z")

</div>

Yes, I was trying to bind them to the Axis Mappings. So I tried using GetInputMotionState via Blueprints but the values(Tilt, Rotation Rate, Gravity, Acceleration) always return 0.

---

<div class="post-metadata">

**Author:** ![Nitrex88](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nitrex88](https://forums.unrealengine.com/u/Nitrex88)\
**Post date:** [April 29, 2014, 6:16am UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750/4 "2014-04-29T06:16:27Z")

</div>

same here. I tried using GetInputMotionState on my character’s player controller (GetPlayerController with index 0) and the values are always 0. I’m using blueprint. I feel like I’m probably not getting the right player controller, but I have the default PlayerController set in my GameMode and assume it should be accessible through my active pawn’s blueprint like I tried (the blueprint is receiving other input that I can move my character with).

---

<div class="post-metadata">

**Author:** ![Marc\_Audy](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/marc_audy/32/710746_2.png) [@Marc\_Audy](https://forums.unrealengine.com/u/Marc_Audy)\
**Post date:** [May 1, 2014, 10:30pm UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750/5 "2014-05-01T22:30:17Z")

</div>

Sorry for slow reply, as a result of this we discovered that the motion controls are not actually hooked up like we thought they were. This is being rectified.

I also went ahead and added the ability to bind Vector Axes to events in the InputComponent.

Apologies for the trouble.

---

<div class="post-metadata">

**Author:** ![Nitrex88](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nitrex88](https://forums.unrealengine.com/u/Nitrex88)\
**Post date:** [May 1, 2014, 10:50pm UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750/6 "2014-05-01T22:50:57Z")

</div>

thank you!!

---

<div class="post-metadata">

**Author:** ![Wraithdrit](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Wraithdrit](https://forums.unrealengine.com/u/Wraithdrit)\
**Post date:** [May 8, 2014, 1:07pm UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750/7 "2014-05-08T13:07:18Z")

</div>

When should we see this? 4.2?

---

<div class="post-metadata">

**Author:** ![alwynd](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alwynd/32/898455_2.png) [@alwynd](https://forums.unrealengine.com/u/alwynd)\
**Post date:** [July 19, 2014, 2:47pm UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750/8 "2014-07-19T14:47:38Z")

</div>

any news on this? 4.2 I got it working by directly reading the InputKeyState, now in 4.3, nothing is working… gonna have to use the default virtual joysticks.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4f69c81c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4f69c81c](https://forums.unrealengine.com/u/anonymous_user_4f69c81c)\
**Post date:** [July 20, 2014, 7:37pm UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750/9 "2014-07-20T19:37:10Z")

</div>

Hi,

i’m using **4.2** and discovered the same problem. GetInputMotionState() always returns 0.  
Can someone please try if this has been fixed in **4.3**? Thank you very much!

* * *

A related question:  
Is there a way to get the current device rotation in absolute values? I’m talking about the absolute rotation of the smartphone, not the new input force on the values.

---

<div class="post-metadata">

**Author:** ![alwynd](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alwynd/32/898455_2.png) [@alwynd](https://forums.unrealengine.com/u/alwynd)\
**Post date:** [July 21, 2014, 5:51am UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750/10 "2014-07-21T05:51:11Z")

</div>

4.3 not working. But performance is better on mobile it seems.

---

<div class="post-metadata">

**Author:** ![Stephen\_Ellis](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/stephen_ellis/32/1210665_2.png) [@Stephen\_Ellis](https://forums.unrealengine.com/u/Stephen_Ellis)\
**Post date:** [July 21, 2014, 6:28pm UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750/11 "2014-07-21T18:28:18Z")

</div>

@alwynd

What device(s) are you experiencing this issue on in 4.3?

---

<div class="post-metadata">

**Author:** ![alwynd](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alwynd/32/898455_2.png) [@alwynd](https://forums.unrealengine.com/u/alwynd)\
**Post date:** [July 22, 2014, 6:22am UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750/12 "2014-07-22T06:22:45Z")

</div>

HI, I tried on the Galaxy Note 3 (ATC) and iOS 7, iPhone 4.

---

<div class="post-metadata">

**Author:** ![piinecone](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@piinecone](https://forums.unrealengine.com/u/piinecone)\
**Post date:** [July 23, 2014, 10:33pm UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750/13 "2014-07-23T22:33:01Z")

</div>

I’m able to output the tilt, etc. with 4.3 on iOS using both the **PlayerController-\>GetInputMotionState** and the **PlayerController-\>GetInputVectorKeyState**. However, as soon as a touch event is registered, all returned values are zeroed. I haven’t figured out how to re-enable them; it appears the touch input cannibalizes the motion input.

Edit: I was wrong. I had an invisible Touch Interface that was (probably) colliding with the GetInputMotionState results. After clearing the touch interface, I’m able to get consistent **tilt** data from **PlayerController-\>GetInputMotionState**.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4f69c81c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4f69c81c](https://forums.unrealengine.com/u/anonymous_user_4f69c81c)\
**Post date:** [July 25, 2014, 7:56pm UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750/14 "2014-07-25T19:56:43Z")

</div>

Thanks for the answer. I’m now using 4.3 and still get 0 values from **PlayerController-\>GetInputMotionState**  
piinecone, what did you do to get this working? I quickly created a new project, used the **Add code to Project** menu to add classes of GameMode and PlayerController. For the GameMode, i simple linked **PlayerControllerClass** to my PlayerController class. Inside my PlayerController, i just overrode **Tick**. At Tick(), i’m calling **GetInputMotionState(Tilt, RotationRate, Gravity, Acceleration)**. Values are always 0 for me.

Did i forgot something?

//PS: i’m testing on android

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_104c9a84](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_104c9a84](https://forums.unrealengine.com/u/anonymous_user_104c9a84)\
**Post date:** [July 27, 2014, 5:52pm UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750/15 "2014-07-27T17:52:42Z")

</div>

Hi, I had the same 0 values on my Android ‘Note 10.1 2014’ and UE 4.3.  
As a quick&dirty workaround i’am getting the gyro info directly from LaunchAndroid.cpp (line 440) thru a global variable.

```
             else if (ASENSOR_TYPE_GYROSCOPE == sensor_event.type)
					{ MyGlobalVariable_motionGyroscope.X = sensor_event.vector.pitch;
					MyGlobalVariable_motionGyroscope.Y = sensor_event.vector.azimuth;
					MyGlobalVariable_motionGyroscope.Z = sensor_event.vector.roll;

						current_gyroscope.X += sensor_event.vector.pitch;
						current_gyroscope.Y += sensor_event.vector.azimuth;
						current_gyroscope.Z += sensor_event.vector.roll;
						current_gyroscope_sample_count += 1;
					}

```

It seems that the surrounding while loop is never ending, so the results are never calculated and send away.  
Hope that helps.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_104c9a84](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_104c9a84](https://forums.unrealengine.com/u/anonymous_user_104c9a84)\
**Post date:** [July 27, 2014, 5:53pm UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750/16 "2014-07-27T17:53:42Z")

</div>

Hi, i made a reply a few lines below. 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_104c9a84](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_104c9a84](https://forums.unrealengine.com/u/anonymous_user_104c9a84)\
**Post date:** [July 27, 2014, 8:50pm UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750/17 "2014-07-27T20:50:59Z")

</div>

I found a better solution (but its still just a temp. workaround!) . I just put the result calculation into the never ending while loop.  
In this way **PlayerController-\>GetInputMotionState** starts working in a ‘normal’ way.  
Just replace **AndroidProcessEvents** in LaunchAndroid.cpp with the following code.  
You can find the code on my UE branch. [1]: [https://github.com/hallifaxx/UnrealEngine/commit/f0ee135e747aff6201962d9d50b13105c730e382](https://github.com/hallifaxx/UnrealEngine/commit/f0ee135e747aff6201962d9d50b13105c730e382)

---

<div class="post-metadata">

**Author:** ![AlwysAnrchy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AlwysAnrchy](https://forums.unrealengine.com/u/AlwysAnrchy)\
**Post date:** [July 28, 2014, 8:32pm UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750/18 "2014-07-28T20:32:18Z")

</div>

Howdy everyone,

I have attempted to recreate the issues that have been occurring with builds on mobile devices and have been successful with Android builds. I have also tested this issue with iOS devices and have have ran into no such issue with the Tilt not showing correctly. Here is the setup that i was using to test the tilt functionality on:

 ![11300-axismappingissueblueprint.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/7/d/37d3debdb62f8f83418cb70eb7df6a71eb46b5b9.png)

I tested this on both the Samsung Galaxy Note 3 and the iPhone 4, iOS 7.0. The numbers where showing correctly for the iPhone, while the Note 3 was only showing zeroes. I have entered this issue into our bug database so the it may be fixed in a future release.

Thanks and have a great day!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4f69c81c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4f69c81c](https://forums.unrealengine.com/u/anonymous_user_4f69c81c)\
**Post date:** [July 28, 2014, 9:28pm UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750/19 "2014-07-28T21:28:41Z")

</div>

Thank you, i hope it might be fixed soon. I think its not an issue with the Note 3, but with android devices in general. My Google Nexus 4 generates only zeroes, too. However, with the old 4.2 i’m now able to get tilt values by overriding InputMotion(). Still testing that out though, as that values seems to be not that useful for me.

For 4.3, it is impossible for me to get values other than zeroes.

---

<div class="post-metadata">

**Author:** ![GrafikRobot](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GrafikRobot](https://forums.unrealengine.com/u/GrafikRobot)\
**Post date:** [July 31, 2014, 7:43pm UTC](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750/20 "2014-07-31T19:43:46Z")

</div>

FYI… I fixed the missing sensor values for 4.4 ([this is the commit](https://github.com/EpicGames/UnrealEngine/commit/ecd98a821a5178b86d6cd857c31c89c13c87c3fc)). You might be able to backport to your local 4.3. Or just wait for 4.4.

[Next page](https://forums.unrealengine.com/t/how-to-set-up-tilt-input-axis-mappings-for-mobile-devices/281750.md?page=2)
