Sign in to follow this  

Unity Detecting 360 motion on mobile (Android, Unity3D)

This topic is 728 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
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

This topic is 728 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Similar Content

    • By Aggrojag
      Hello!
      I'm working on a game that is quite personal to me. It touches on my own depression, obsessions, phobias, etc. It's a narrative driven dark comedy with some small aspects of platforming and puzzle solving. The project is rather small as well. It touches on topics such as suicide, mental illness, family, corruption, free-will, and redemption.
      First, I'm looking for a 2D animator that can compliment the style of the attached image. The player character's animations will be a bit more extensive than a typical platformer. There will be many death animations, and some other strange dealings with the character that will need animation. Other items will include some objects in the world that are in need of animation. All static pieces of art will be handled by the artist that drew the attached image.
      Second, I'm looking for a male voice actor. There will be at minimum two characters that will need to be brought to life through vocals. They are a very core part of the game, though they will never be shown on screen. As a reminder, this is a rather dark comedy, so be prepared for some insanity in your portrayal of these characters. The first voice is that of a game show host's voice, while the other will be a devilish voice (without SFX, I think it cheapens it, does not necessarily need to be a low voice, this is more about the portrayal than how the voice sounds).
      Last, I would love to have an editor on board. More than just avoiding disaster in the writing, I'm looking for someone that can elevate it. There is not a ton of writing that will be in the final project, but it's important enough of an aspect to be trying to bring someone in to help with it.
      To those interested:
      I have a crappy prototype that exists, along with a couple game design docs. More than anything, I'd like to present the project through a voice chat via discord to any interested. Discord - Bobdul Thundercuck#4590
      I do plan to post this on itch.io and wherever else I can put it that makes sense. I fully expect to make nothing off this project, as should you. However, in the case that money is made, a rev share model will be in place.

       
      Edit: Editor position has been filled, title has been changed to reflect this, and crossed out the section detailing this.
    • By William Edmeades
      Hey guys and girls,   Have you ever found yourself trying to apply for a job to be a game developer or a game artist? Maybe a sound engineer or a script writer? Only to not even get an interview due to lack of ‘experience’, teamwork projects or released game titles you have worked on? I have for sure. The game industry is hard and competitive to get into for someone new, especially when you might have a full time job or even have to support a family. So I have come up with an idea and I wanted to throw something out there to see if people could be interested in such an idea.   What if you could be part of a virtual game development company? A place where you can work on projects with a team of people from the internet, soon to be known as your colleagues, which could be from anywhere in the world all working at your own pace when you have time to do as little or as much as you want.   The idea is we can create the power of a company and release titles together. Not only do you then have a released game title you have worked on under your resume, but also work experience, team work skills, and the power of helping each other and learning from each other.    My dream idea is to create a solid place for people to join a party and develop ideas and create games and level up it experience points.   As far as money is concerned, the games would either be released for free or any money would go towards charity, it’s not about making money, it’s about building a career or justness having fun building games and socialising with like minded people.    I want to make something amazing, I think it would benefit me, and I think others who are serious would benefit greatly too.   I await your critasism on the ‘prototype’ idea, I just wanted to see how many people would be interested in such a concept. And if you are very much into the idea, let’s make it happen.   Thanks,   Will. www.feelingterrible.com
    • By red1m3n
      Hi I'm a hobbyist getting together a team to pursue game creation, we'll do both 2D and 3D games, we would definitely build different types of games, and hopefully have a great time doing it. you dont have to have much experience, just enough that you think you can fill the position. I have plenty of ideas for games that I'd love your help with, and am completely open to fulfilling your game ideas . As of right now this is a for fun project thing, but if me and my team are satisfied with our work it can be published to steam or other platforms. 
      The positions I'm currently looking to fill are:
      2D Pixel artist
      3D Modeler 
      C# programmer
      Musician/Sound engineer
      I am currently working on a project it is a 2D Merchant adventure game with survival elements. It does not have a name yet, that's because I'm bad with names. 
       
      If interested please feel free to leave me a PM or email at dealtavu@gmail.com so we can talk more about it..
    • By NDraskovic
      Hey guys,
      Like the title says, I'm trying to find out if it's possible to automatically set which scenes will be built for different platforms. For instance, I have scenes that I want to include when building for PC, but exclude them for mobile platforms. Is it possible to do this automatically (by some settings file, or by coding some editor extension), or do I have to manually (de)select them each time I switch platforms?
      Google just keeps sending me to the documentation sites about the regular publishing, but I can't find information about this problem.
      Thanks in advance
    • By Slack Dragon
      Download here: https://slackdragon.itch.io/dungeon-chop-chop
       
      Dungeon Chop Chop is a Singleplayer / Co-Op Rogue-like Adventure game currently in development. 
      All feedback is greatly appreciated
       
      About:
      An admirable soul tainted by darkness has laid waste to 
      the land. He has robbed civilians of their riches and lurks in 
      a dungeon locked with sorcery and guarded by monsters. 
      With treasure to claim, demons to slay and eternal fame to 
      be won, adventurers travel from far and wide to test their 
      strength against this enemy. 
      Many have tried and not a single one has returned! 
      Will you be the challenger who finally breaks the seal and 
      restore peace to the land? 
       
      Consider supporting us at:     https://www.patreon.com/SlackDragon
      Check us out on Twitter:    https://twitter.com/SlackDragonDevs
      Designers:
      Lead   Shannon Stefan Programmers:
      Lead  Harrison Jack Artists:
      Jerome Tin David





  • Popular Now