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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Gravtiy/Tilt motion on Android device is twitching and very sensitive, is there a way to smooth this out?


Basically I have just started using UE4 and getting use to this amazing blueprint stuff. I'm testing out camera controls by the orientation of an android mobile device to look around a 3d enviroment or to change the rotation of an object by at least 180 degrees on each axis. It sort of works but as you hold the device the camera movement is very sensitive with a random twitching glitch.

I have tried methods from older answers and have so far come up with this current blueprint below:

Screenshot of current blueprint

It tries to reduce sensitivity but it is also restricting movement. The crazy twitching is probably caused by this blueprint so i know I made a mistake somewhere.

Any way to do this better?



Product Version: UE 4.11
001.png (146.5 kB)
more ▼

asked Apr 20 '16 at 06:23 PM in Blueprint Scripting

avatar image

13 2 3 6

avatar image Peter_M May 07 '16 at 03:13 PM

Well I tried everything I could think of, so I have to assume it's a bug with motion events for Android devices.

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

3 answers: sort voted first

Yes. You can make it smooth.

After over a year of improving the results myself over the course of the project, but never quite solving the twitchy problem, a new advisor to our company, who is an expert gameplay engineer, came up with an elegant and perfectly effective dampening algorithm. It really works.

I've experienced a lot of heartache with tilt on mobile, trying to make it to actually be smooth, and I've seen many others here that have tried and failed as well... so here is the real, actual solution:

![alt text

This fires off every frame. You can either power it with Tick, or with a looped Timeline. I recommend using a looped Timeline, so you can turn it off/on at will. Tick in Blueprints seems to impact performance more than Timelines, at least as far as my testing has revealed.

Here's what's happening:

  1. Mobile Tilt Input is being received from the hardware, whether that's Gravity, Tilt... whatever. It handles a single axis value. Before setting it previous to this algorithm, do whatever multiplication you need to do to expand the range of motion in your game relative to the device's motion.

  2. Tilt Array contains 5 array elements as default. This algorithm stores previous frames and averages them for a final output. The amount of array elements you have it set to will determine how many previous frames are stored in the array. 5 works just fine, but feel free to play around.

  3. Tilt Array Index is used to change what element in the array the current frame's value is being stored in.

  4. After setting the array element, increment the array index, and then modulo the resulting index with the length of the array. What this does is reset the index back to 1 if the most recent array element that had a stored value was 4 (5th element), or whatever your max is. If not, it simply lets it increment and moves on.

  5. Last Index of the ForLoop is set to the highest array element, so array length - 1.

  6. Loop body adds up all values of the array.

  7. On completed, divide Tilt by the array length (5, or whatever you want) and output final value.

TL;DR version: Store previous frames and average them. Make sure Tilt Array has 5 array elements as default, or whatever amount you wanna try. Just do 5 first.

Try it out and be happy.

more ▼

answered May 10 '16 at 03:48 PM

avatar image

DG Gage
1.6k 62 31 129

avatar image Peter_M May 10 '16 at 11:41 PM

Wow thanks for your answer, great to know it can actually be done with blueprints. I will try to follow this and pick up where I left off.

avatar image Peter_M May 13 '16 at 12:20 PM

Yep it works and I'm happy.

Since I needed 2 axis values to be dampened I got this running for X with another for Y in a Sequence. It appears to work fine, is that an efficient approach to manage it?

Thanks again and send my regards to the expert gameplay engineer.

avatar image DG Gage May 13 '16 at 02:08 PM

Aw yis.

That works. But I find that for the sake of good programming principles, copying nodes/code like that usually means there's a more simple and dynamic solution. You could actually just use a vector rather than a single float for the algorithm input/output. Change the Tilt Array to a vector array, and Tilt to a vector. For setting your Mobile Tilt Input (also now a vector) previous to the algorithm, you'd use a Make Vector and plug in each axis input to the corresponding vector axis. It's up to you if you wanna use 1, 2, or all 3 vector axes; one of them being 0 won't matter as long as you aren't actually using it later. I set it up with a single float input/output because I'm only using a single axis from Rotation Rate to do my thang.

Will do!

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

I was implementing exactly the same solution as described by DG Gage but an "average" by definition is always affected by the extremes of the data that means that if at any moment you get an erratic value your whole array "history" is affected for example 1,2,2,30,1 then you get a bad movement until the history removes the "30". There is fashion/mode (maybe i am translating bad, my native language is spanish) wich gives you the most repeated value from your data so i implemented it and got nice results by combining it with average

more ▼

answered Apr 14 '17 at 06:16 AM

avatar image

11 1 2

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

Couldn't you just use the axis value of the Rotation Rate rate event directly?

Rotation Rate Rotation Rate Help

more ▼

answered Apr 20 '16 at 06:35 PM

avatar image

2.1k 67 84 77

avatar image Peter_M Apr 20 '16 at 07:10 PM

I just tried that directly to the SetWorldRotation function and its behavior is totally erratic and not controllable.

Also tried it with the rest of the blueprint, connecting it from the 'Break Vector' part and it was barely responsive.

avatar image CleanCut Apr 20 '16 at 07:31 PM

Maybe you'll have better luck with the other motion events?alt text

avatar image Peter_M Apr 20 '16 at 07:47 PM

Yes before posting this question I have tried all of these motion events, each with their own odd quirks. So far, I get better results from using the gravity sensor, but not without the current problems.

(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