x

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

Product Version: Not Selected
Tags:
more ▼

asked Mar 02 '15 at 12:50 PM in Blueprint Scripting

avatar image

DRob
5 1 3 4

avatar image DG Gage Mar 03 '15 at 04:07 PM

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

avatar image DRob Mar 04 '15 at 03:27 PM

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

avatar image DG Gage Mar 04 '15 at 03:49 PM

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.

avatar image jeffvoigt Mar 04 '15 at 03:53 PM

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

avatar image DRob Mar 04 '15 at 10:09 PM

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.

(comments are locked)
10|2000 characters needed characters left

9 answers: sort voted first

I moved to the forum. I uploaded my project file there. link text

more ▼

answered Oct 08 '15 at 09:36 AM

avatar image

DRob
5 1 3 4

(comments are locked)
10|2000 characters needed characters left

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.

alt text

alt text

more ▼

answered Mar 04 '15 at 04:16 PM

avatar image

DG Gage
1.7k 62 31 129

avatar image DRob Mar 04 '15 at 10:03 PM

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.

avatar image RedParis Apr 01 '15 at 01:18 AM

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

avatar image DRob Apr 03 '15 at 11:27 AM

I posted my solution below.

(comments are locked)
10|2000 characters needed characters left

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.

more ▼

answered Mar 03 '15 at 03:12 PM

avatar image

jeffvoigt
423 19 34 61

(comments are locked)
10|2000 characters needed characters left

Thanks for your answer(s). 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.

more ▼

answered Mar 03 '15 at 04:26 PM

avatar image

DRob
5 1 3 4

avatar image DG Gage Mar 04 '15 at 03:52 PM

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

(comments are locked)
10|2000 characters needed characters left

First Part:

As promised i offer my complete solution here: alt text alt text alt text alt text alt text

more ▼

answered Apr 03 '15 at 11:20 AM

avatar image

DRob
5 1 3 4

avatar image DG Gage Apr 03 '15 at 12:26 PM

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

avatar image DRob Apr 03 '15 at 01:03 PM

It feels pretty smooth. I use my "smootharray" function to take 10 values and smooth them. So there is no "fast" movement which leads to illness.

avatar image DG Gage Apr 03 '15 at 01:09 PM

Why does Mobile HDR matter?

avatar image DRob Apr 03 '15 at 01:17 PM

If i enable it i get nothing rendered. (one side is complete black)

avatar image DG Gage Apr 03 '15 at 01:23 PM

Well that's a whole other problem! Mobile HDR works fine for Android devices, at least any time I've worked with them

avatar image DRob Apr 03 '15 at 01:50 PM

Yes, it works fine for single rendered applications.

avatar image DG Gage Apr 03 '15 at 03:01 PM

Interesting, so what are you working on that isn't single rendered? Mind explaining what that means?

avatar image DRob Apr 03 '15 at 03:11 PM

I mean splitscreen rendering isn't working on android.

edit: i mean with mobile hdr enabled

avatar image DG Gage Apr 05 '15 at 02:47 AM

Oh okay. Is this a local multiplayer game or something?

avatar image DRob Apr 05 '15 at 08:58 AM

No and Yes :-) It's a solution to "simulate" stereo rendering on android device, because at the moment there is no such think around. (like cardboard plugin for unity)

avatar image DG Gage Apr 05 '15 at 03:36 PM

Oh that's cool :)

(comments are locked)
10|2000 characters needed characters left

Second Part: alt text alt text alt text alt text

basic-vr-part4.png (528.5 kB)
basic-vr-part5.png (407.6 kB)
basic-vr-setup.png (368.2 kB)
collision.png (473.7 kB)
more ▼

answered Apr 03 '15 at 11:21 AM

avatar image

DRob
5 1 3 4

(comments are locked)
10|2000 characters needed characters left

Last Part: alt text alt text alt text alt text

settings1.png (92.2 kB)
settings2.png (130.3 kB)
smootharray.png (222.1 kB)
rewired-input.png (529.6 kB)
more ▼

answered Apr 03 '15 at 11:22 AM

avatar image

DRob
5 1 3 4

avatar image Dhiego Lucio Sep 16 '15 at 02:18 AM

Man, I made step by step and something funny happened: when I used with first person example, the second player spawn was 180 degrees turned to first player. Then I decided to make it from a blank project, and everything is okay........but everything run to the left (in fact is just to 1 direction, if I rotate the game spawn point 90 degree, will run to back or forward) till fall or some wall holding.... same on mobile. really weird :/

avatar image DRob Sep 17 '15 at 08:45 AM

Hey. I looked through all code and found a big mistake i made. There is a mistake in the "smootharray" function. You need to cut the connection between "set tempfloat" and "return node". Then you need to connect the "for-each-loop" - completed node to the return node.Look at this screenshot. alt text Further i put my project apk in this thread. Feel free to test it.

smooth.png (280.1 kB)
(comments are locked)
10|2000 characters needed characters left

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.

more ▼

answered Apr 03 '15 at 11:24 AM

avatar image

DRob
5 1 3 4

avatar image RedParis Apr 04 '15 at 09:16 PM

Thanks for posting this! Everything seems to work for me, except that the 2nd player is spawned at -179 degrees rotation from the 1st player, and the 10 unit offset (for the left eye/2nd player) doesn't seem to be executing. I'm probably overlooking something, but I can't find any reference to the rotational offset anywhere...any ideas?

avatar image DRob Apr 04 '15 at 10:41 PM

Maybe you miss the Basic-VR-Setup blueprint. It is executed on start. "Event begin play" .Look first screenshot and basic-vr-setup.png. It rotates the new spawned player. Also make sure that the both players don't collide each other.

avatar image RedParis Apr 05 '15 at 07:49 PM

I think I was missing a connection somewhere. But now, when I package it and play it on my android phone (HTC One, running Android 4.4.3), I don't get any movement by tilting. Looking for a missed connection somewhere, but wondering: Do you know how to mimic tilt in the UE4 editor viewport during playback? Is it even possible?

avatar image DRob Apr 05 '15 at 08:31 PM

I think you can't test it in the editor. You can only move with WASD. I use this to test if there is no collision. I dont know if you missed a connection but you should first try if you get input data from sensors of your phone. alt text Use something like this (screenshot). Connect it with GetInputMotionState. If you get data the problem is somewhere else,if not then there is maybe a android configuration problem. But first try to debug.

debug.png (332.7 kB)
avatar image Kalistee Sep 05 '15 at 10:30 AM

Hello, could you PLEASE upload your blueprint or project file here? I tried everything but it isnt working for me.. i will be really thankful

avatar image DRob Sep 16 '15 at 01:49 PM

It doesn't work anymore. I will work on it and will post an update if i find a solution.

avatar image DRob Sep 19 '15 at 11:40 PM

Does my apk work for you ?

(comments are locked)
10|2000 characters needed characters left

Hey guys. I uploaded my project apk. I tested it on my s6 edge and it runs pretty well. Can someone please test it too ? I will upload all the stuff needed if someone confirms that this runs well on other mobilphones too. download

more ▼

answered Sep 16 '15 at 10:02 PM

avatar image

DRob
5 1 3 4

avatar image MZorba Sep 25 '15 at 06:46 PM

Can you post solution? I am trying to create it on my own but it isnt working really well.. I only have working camera movement for moving phone up/down. Left and right is the problem, I dont know from where to read data about left/right phone movement... Apk you posted requires lots of permission, so not really sure should I install it :S

avatar image DRob Sep 29 '15 at 09:02 AM

The permissions are from unreal engine. I'm busy working right now, but i will upload my folder. Any suggestions what is realy necessary? Because my project folder is almost 3 GB in size.

avatar image MZorba Oct 07 '15 at 09:37 PM

If it isn't a problem for you, you can upload whole folder. Or if you have done it with blueprints just printscreen BP that controls your camera movement. Thanks a lot!

avatar image ricardocrh Oct 05 '15 at 01:23 AM

Hello DRob,

Thanks for helping. It wouldn´t be a problem to download 3GB, really. But of course, if you could get rid of some non-essencial assets, that would be great.

Thanks again, Ricardo

(comments are locked)
10|2000 characters needed characters left
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