How can I use Android tablets tilt through blueprint?

How does one go about mapping the Accelerometer and Gyro from a tablet using Blueprints? I have an actor that I would like to rotate using the accelerometer (I believe). My project already ports to the android fine, now I’m just trying to start using the inputs from the tablet. Would this be better to do in code right now?

No code needed. You can use Get Player Controller > Get Input Motion State, and use those outputs for some nodes like Set World Rotation or Set Relative Location. Fire those nodes with Tick or a Timeline. I recommend a Timeline so you can control when it’s firing and keep it in its own little node network without having to attach it to Tick. I think Tick is icky and never needed in BPs.

Also, I found that Android tilt can be janky. So here’s my agony-saving tip for you:

Use Gravity from Get Input Motion State. With Rotation Rate, use Break Vector and check if Y (or whatever your primary axis will be, but probably Y; same for your Gravity output) is between -.1 and .1. If so, round your Gravity Y value to the nearest 10th. Otherwise, leave it be. This essentially detects if the player is “trying” to steady their aim, and smooths it. When they aren’t it lets it move naturally.

After some real heartache, this boosted our game’s playability hugely, as it relies heavily on aiming with tilt.

Hope that helps you out :slight_smile:

Awesome thanks. I’ve got it responding to my tablet now. I still need to calibrate it. Any recommendations for that. Currently my direction indicator is wiggling a good deal (and in the wrong directions) so I was wondering if there is an easy way to iron out the remaining calibrations. For instance, I can’t tell right now if the tablet is able to influence inside of Unreal for debugging. But when I ported it to the tablet and ran it I could see the indicator moving back and forth as I did with the tablets tilt. So I know it’s on track but I need to adjust how it’s being told to rotate and so on. Is it just a dial in and build situation?

You’ll have to study the experience as if you were a player. Use Print Strings with those Get Input Motion State values. How far should you have to tilt left or right? You’ll multiply your Gravity Y by some value to perfect that, and use Branches to monitor hard limits (ex. never rotate more than 70 degrees left or right). You’ll also study Rotation Rate, determining within what range is a player trying to steadily aim.

Unfortunately, the only to do this is to keep building it onto your Android device in development with those Print Strings, make changes in the engine, repeat. Real-world note-taking is recommended :slight_smile:

But with this finalized method (I’ve destroyed myself with several other less-effeftive and massively more complex methods), that’s really the extent of work that was necessary to achieve good gameplay. It’ll never be as good as iOS, but that’s just a difference in hardware.

PS. Feel free to also mess around with value smoothing outside of the Rotation Rate aim check, if you feel it’s necessary.

Do you want more info on this or are you ready to roll? I ask for tracking purposes, so we can close the question or not.

Totally happy to give you as much help as you want :slight_smile:

Thank you, I’m good with this part. I’ve got input coming in, just gotta do the work now. I’ll toggle the answer.

Here, check this out, you may find it helpful :slight_smile:

Hey bro , Can you show me the Blueprint ? I’m doing it too :slight_smile:

Sorry for resurrecting this post. I’m working with a project using tilt, and can’t get it to respond on the testing device. Could you possibly show the BP that worked?

Hi! Sorry for the third resurrection but I am struggling with the same issue too so any BP demonstration would come more than handy!