Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  5. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Problems with gyro camera rotation.

Discussion in 'AR/VR (XR) Discussion' started by MGlolenstine, Dec 4, 2018 at 2:30 PM.

  1. MGlolenstine

    MGlolenstine

    Joined:
    Sep 1, 2014
    Posts:
    2
    Hey, this is my first post, please be gentle.

    I want to rotate camera in the game, just as I am moving the phone(Just like VR does it).

    for that I'm currently using this piece of code
    Code (CSharp):
    1. cam.transform.Rotate(-gyro.rotationRate[0], -gyro.rotationRate[1], gyro.rotationRate[2]);
    but it doesn't really do the job. When I try the app out via Unity Remote(this could actually be the problem), and if my phone was perfectly flat on the table, I fidget with it and return it back to the same position as it was in before, camera is still rotated and/tilted. It's just like I'm losing some of the information that the gyro should be sending.

    Is there something I'm doing wrong and/or would be better done with something else?

    Thanks!

    EDIT: Just tested... UnityRemote is not the problem.
     
    Last edited: Dec 4, 2018 at 2:56 PM
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    7,434
    You're not doing anything wrong. It's just that what you want to do is pretty much impossible. VR doesn't do it without fancy extra hardware. AR does it only by finding (through some very deep and fancy algorithms) visual markers in the environment, and even with all the muscle of Apple or Google behind it, it still shifts/drifts sometimes. The gyros are just not precise enough to not accumulate error over time, and probably never will be.

    Depending on your goals, it's possible you could do somewhat better by using the compass rather than the gyro. But that too will only get you so far.
     
  3. MGlolenstine

    MGlolenstine

    Joined:
    Sep 1, 2014
    Posts:
    2
    Wait, so you're suggesting that I use compass for rotation around Y axis and accelerometer for everything else?

    Thanks for the reply!
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    7,434