# How to use Get Input Motion State to "Look around"

Can someone point me in the right direction please?
I want to use android motion sensor data to look around in the level.
My first attempt was to get the data (gravity) and break it into xyz (break vector) and afterwards i add the x value to
“add controller pitch input”. But i think that isn’t the correct way to do this.

After you do an EnableInput you can call GetTilt. Then take the result of that and pass that into a MakeRotationFromAxes as a Forward vector. That will give you the current rotation. I’m currently doing this now but still have a few issues I need to address. I’m going to post them in another thread.

We have a game based on tilt for looking around that functions very well. We use the Tilt input, with several equations to optimize it to our exact gameplay needs. What exactly is the issue you’re having? It’s likely an issue I’ve previously run into and overcame

This is what I just posted! I hope you can help!

GetTilt never worked for me.
Currently i found i way for up and down. (still working on left and right)
I use (as blueprint):

GetMotionInputState → take Gravity → Break Vector → take Z Value and then i do rad2degree conversion → some math to “smooth” the value → Make Rot → use Pitch pin → Set Actor Rotation (i my case a pawn with camera)
This works good when deployed on an android phone.(I can look up and down)
I want to know if this is the right way of doing such thing.

Finally i was able to use tilt for up/down. Do you use tilt also for left/right?

We use it for left/right, yes. I convert it to degrees with a simple equation that allows for control over how much the tilt input affects the movement. For Android, there’s an additional equation needed because its 0 value for tilt is with the phone facing down, which is weird.

That’s essentially how I did it. I used Gravity for awhile but ended up using Tilt because it had larger values and therefore was a bit smoother when converted

I wish I could get access to what is going on here. All I’m trying to do is replicate the events when a device rotates the screen 90 degrees (portrait, landscape, upside down portrait, etc). My game only supports portrait but I still want to know when the user turns the device like that so I can simulate a few UI sprite elements to rotate (not the entire game/viewport)!!

Maybe this can help you guys. For our game, we needed the player to rotate 70 degrees left and right, so from values of -70 to 70. The first pic you see there checks if it’s an Android device, and applies some math to adjust its tilt input values. You can see the comment box where it says “2.5 to pi; -pi to -2.5”. That was a result of testing the hardware values and determining how far we wanted the player to have to tilt to reach 70 degrees.

The second pic shows the Android Tilt Conversion function, which takes the hardware values of pi/-pi with the phone screen facing up and 0 with the phone screen facing down. This equation flips it so 0 is up.

The other equation in that function multiplies the values in such a way that it will go to 70 degrees with the amount of physical tilt we wanted. It then smooths out the values a bit before sending it out as Converted Tilt.

From there, it’s a as simple as applying that value to the Yaw input of the character rot. That’s for tilting left/right with a landscape view. I also used some scripting to limit the character rotation so that when it reaches -70 or 70, it no longer rotates.

The Tilt Capture thing you see in the first pic is something different. I found Android tilt to be a bit wonky, so that was an additional and kinda tricky measure to stabilize it even more. I’ll elaborate if you want.

Let me know if this was what you were looking for.

1 Like

Thats what i was looking for. Thank you for your help. I’m able now to look in every direction on my sbs game. I need to do some more math because you get “motion illness”.Its too fast. If im ready i will post my blueprint. I guess more people are interested in this.

I don’t really understand what you are trying to do but use tilt to get a value and convert it to degrees. Then you can check: -180 = facing down for example.
You have to write something like : if -90° then do something and if +90° do something else(blueprint: branch). In your case rotate your sprites.

DRob,
Any chance you could post your blueprint? Just curious if you got it to work.

First Part:

As promised i offer my complete solution here:

1 Like
1 Like
1 Like

This is my complete Solution for Android VR.
The basic idea is to spawn a second player and move him the same way as the first player.
It works pretty well on my S5.
If you have questions feel free to ask.

I posted my solution below.

Why does Mobile HDR matter?

How smooth does that feel on Android? I was never able to get Android to the level of iOS tilt smoothness, but I made it good enough to have a fun experience. I’m curious how well this works. It’s a little different than my setup, but I think has similar principles