Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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

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?

Product Version: Not Selected
more ▼

asked Apr 26 '14 at 08:47 PM in Using UE4

avatar image

88 7 11 13

avatar image alwynd Jul 19 '14 at 02:47 PM

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.

avatar image Stephen Ellis ♦♦ STAFF Jul 21 '14 at 06:28 PM


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

avatar image alwynd Jul 22 '14 at 06:22 AM

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

avatar image germ1389 Apr 17 '15 at 03:09 PM

Any News on this subject? i'm trying to get on the tilt action but it only goes either up and down or right and left. Please Advise.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

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.

more ▼

answered Apr 26 '14 at 09:21 PM

avatar image

Marc Audy STAFF
2.2k 42 35 95

avatar image TickleForce Apr 27 '14 at 11:48 PM

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.

avatar image Nitrex88 Apr 29 '14 at 06:16 AM

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).

avatar image Marc Audy STAFF May 01 '14 at 10:30 PM

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.

avatar image Nitrex88 May 01 '14 at 10:50 PM

thank you!!

avatar image Wraithdrit May 08 '14 at 01:07 PM

When should we see this? 4.2?

avatar image Xetatronics Jul 20 '14 at 07:37 PM


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.

avatar image alwynd Jul 21 '14 at 05:51 AM
  1. not working. But performance is better on mobile it seems.

avatar image piinecone Jul 23 '14 at 10:33 PM

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.

avatar image Xetatronics Jul 25 '14 at 07:56 PM

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

avatar image halifacx Jul 27 '14 at 05:53 PM

Hi, i made a reply a few lines below. :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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: alt text

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!

more ▼

answered Jul 28 '14 at 08:32 PM

avatar image

[Epic] Gribbs ♦♦ STAFF
11.8k 292 14 77

avatar image Xetatronics Jul 28 '14 at 09:28 PM

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.

avatar image GrafikRobot Jul 31 '14 at 07:43 PM

FYI.. I fixed the missing sensor values for 4.4 (this is the commit). You might be able to backport to your local 4.3. Or just wait for 4.4.

avatar image pleaseluggage Mar 16 '15 at 03:36 AM

Since I'm a noob, I can't make the leap from making objects tilt based on my device's tilt and controlling my player. Ultimately, I'd like to get my scene started as a FPS scenario (but not with the gun). I've figured out how to drop the FPS BP class into the scene but haven't yet been able to actually control the player.

Thank you if you have any insights.

avatar image [Epic] Gribbs ♦♦ STAFF Mar 16 '15 at 02:39 PM

Howdy pleaseluggage,

Would you be able to create a new post about being able to control the player in the level? This will provide an update for anyone else attempting to solve the same thing you would be.

Thanks and have a great day!

avatar image germ1389 Apr 17 '15 at 03:09 PM

Any News on this subject? i'm trying to get on the tilt action but it only goes either up and down or right and left. Please Advise.

avatar image [Epic] Gribbs ♦♦ STAFF Apr 17 '15 at 05:15 PM

Howdy germ1389,

this issue has been resolved since this was first reported. What kind of issue would you be having with your device or setup? What version of UE4 would you be using and is that version a source build or a binary build?

Any additional information would be greatly appreciated.

Thanks and have a great day!

avatar image germ1389 Apr 17 '15 at 05:31 PM

I am using a Samsung Galaxy Tab Pro and a Samsung Galaxy S4. The Build is 4.5.3. The setup i'm using is Tilt to get the movement to the rolling ball. Every time i apply the tilt function to the MoveForward Axis Mapping goes Up and Down, and whenever i add tilt function to MoveRight Axis Mapping goes Right and Left. If i put Tilt in the 2 it moves diagonally only. How do i make the tilt make the ball go Up, Down, Left and Right? I'm using 4.5 but willing to go up to 4.7 if needed.

avatar image [Epic] Gribbs ♦♦ STAFF Apr 20 '15 at 06:50 PM

Hey germ1389,

Would you be bale to share a couple screenshots of your Blueprint so I may be able to see what is occurring for you? This will be the best way for myself to debug this issue or help with your setup.


avatar image germ1389 Apr 22 '15 at 11:45 AM

There is no blueprints involved, i just added the "Tilt" Key to the Axis Mapping under Input on the Project Settings. Small update: i tried upgrading to the 4.7 but the problem remains.

avatar image [Epic] Gribbs ♦♦ STAFF Apr 22 '15 at 01:51 PM

Hey germ1389,

I have just tested this internally and have been able to see what you have been experiencing. This is working as intended though. If you add tilt to either MoveRight or MoveForward, It is only going to stay along those lines. You would have to set it up in blueprints to correctly reference the tilt of the mobile device.

Think of the mobile device as your keyboard keys. You press 'W' to move forward and 'A' to move left. If you move them both, you move in a diagonal. This is how tilt is being referenced by adding it to the Axis Mappings. Since it is added to both MoveForward and MoveLeft, this is why the diagonal movement is seen.

Please let me know if you have any additional questions.

avatar image Aerohand Oct 29 '16 at 02:26 AM

hi there im testing with my android phone huawei and samsung with tilt value, however, the Y axis always returns 0. do you have and clue about that? thank you very much!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Jul 27 '14 at 05:52 PM

avatar image

21 3 5

avatar image halifacx Jul 27 '14 at 08:50 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question