Jump to content
  • Advertisement
Sign in to follow this  
Volvary

Unity Detecting 360 motion on mobile (Android, Unity3D)

This topic is 1064 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone, Volvary here.

 

As some might have seen recently, I've been working for a little while on an Android game with sound and rotation as the main components for input/output.

 

Well, one of those mechanic has given me quite the mental workout and that is the rotation.

 

So first off, I will be explaining what I mean by rotation. What I want to achieve is what could be described as AR (Augmented Reality). Think of it as the phone acting as a "window" to the game world. By moving the phone around, you would be able to move your view inside the game and see what hides in that direction.

 

I have tried multiple things but I can't seem to get it to work.

 

So in order:

 

First I tried rotating my camera by Input.acceleration. By itself, it gave off something very imperceptible. Scaled to greater sensibility, it revealed to be detecting 2-5 motions a frame even with the phone laid on a surface, causing sporadic movements.

 

Then I tried Input.gyro (making sure to activate it). But whatever I tried, I couldn't get any value to display anything else than 0. (Does the phone I am testing on has a gyro? I have no idea, I still suck when it comes to mobile dev)

 

The thing is I'm pretty sure it can be done. (And with only the accelerometer, if I'm not wrong, making it stable) But I'm dumbfounded as to why it failed. And since I don't know the proper term for what I'm trying to do, I can't find a single piece of information that can help me right now.

Share this post


Link to post
Share on other sites
Advertisement
I've never used it before, but this sort of sounds like what you want (Rotation Vector Sensor):

http://developer.android.com/guide/topics/sensors/sensors_motion.html#sensors-motion-rotate

There is also one specific to games that you might try:

http://developer.android.com/guide/topics/sensors/sensors_position.html#sensors-pos-gamerot


The first one appears to use the Earth's magnetic field as a reference, and the second is likely integrating gyro data. Edited by Nypyren

Share this post


Link to post
Share on other sites

The thing is I'm pretty sure it can be done. (And with only the accelerometer, if I'm not wrong, making it stable)

 

It can be done, but you will have a really hard time trying to do it with just the accelerometer.

 

The main problem with using earth gravity as a reference for which way you are facing is that the vector points the wrong way! Since it points down, you have no way of knowing the difference between looking north and looking south. (or any other direction)

 

You will need more sensors.

 

As you have also noticed, the sensors is generally pretty noisy, you will never get an exact value from it, but they need to be smoothed over several frames.

This on the other hand might make the movement sluggish.

 

Thats another reason to use more then one type of sensor, they can cancel out each others errors making the end result more stable, if combined in the right way.

 
A better idea than to try to solve this yourself (It's not an easy problem), could be to use an API where the motion sensors have already been integrated to an orientation
Nypyren has linked to such APIs.
Edited by Olof Hedman

Share this post


Link to post
Share on other sites

 


The thing is I'm pretty sure it can be done. (And with only the accelerometer, if I'm not wrong, making it stable)

 

It can be done, but you will have a really hard time trying to do it with just the accelerometer.

 

The main problem with using earth gravity as a reference for which way you are facing is that the vector points the wrong way! Since it points down, you have no way of knowing the difference between looking north and looking south. (or any other direction)

 

You will need more sensors.

 

As you have also noticed, the sensors is generally pretty noisy, you will never get an exact value from it, but they need to be smoothed over several frames.

This on the other hand might make the movement sluggish.

 

Thats another reason to use more then one type of sensor, they can cancel out each others errors making the end result more stable, if combined in the right way.

 
A better idea than to try to solve this yourself (It's not an easy problem), could be to use an API where the motion sensors have already been integrated to an orientation
Nypyren has linked to such APIs.

 

 

 

Oh, I see.

 

Thanks to both of you, I will be trying to apply what you just brought up to me and see if I can make it work. I'll be updating relating to what I manage to do.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!