Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by yetstay · Mar 28, 2012 at 07:09 AM · camerarotationquaterniongyroscopegyro

3D camera relatively using gyro a la N.O.V.A. 2

Hello awesome people! :) I am trying to make a 3D camera that uses iphone 4's gyro. I've researched quite a bit on google and unity forum and unity answers and found this http://forum.unity3d.com/threads/98828-sharing-gyroscope-controlled-camera-on-iPhone-4/page2?highlight=gyroscope and this http://forum.unity3d.com/threads/75288-Gyroscope-Quaternion-to-Unity-Camera-%28HELP-PLEASE!%29 and read whole bunch of other links and I have the basic idea about how to use gyro for the game's main camera. Basically, offset the raw data(attitude) gotten from gyro and apply a fixed quaternion rotation to make it meaningful (although I don't have a slightest idea how phoberman came up with the numbers in his script) then apply that rotation to camera. I've gotten the script to work in my prototype for now.

My problem is this. I am trying to make a camera that uses gyro, but relative to the current position(or rotation) of the phone and also incorporate a finger control , a la N.O.V.A. 2. The camera in that game starts looking "forward (vector3(0, 0, 1) in the game world, if you will)" regardless of the position you are holding the phone, then moves according to the gyro using that "forward" as a reference. Then you can still look around by touching anywhere on the screen with one finger and moving it around.

The first step would be making the gyro relative, not absolute (as in making the camera point where the gyro is pointing) as what my current prototype is doing. Right now if I start my game holding the phone downward, it will start looking down, not "forward." I have been thinking about it and thought if I applied a quaternion rotation from the gyro's attitude to "forward", the game would start and the camera would look "forward." It did, but the movement update was not really working as I expected. Then I tried getting two directional vectors from where the camera is looking(governed by gyro) and the initial forward, got a quaternion rotation from them using fromtorotation function, and tried using it but it didn't work either.

What I had in my mind was to get some sort of fixed rotation or a fixed angle between the initial gyro lookat and the initial "forward" vector then to apply it constantly whenever the camera's moving, but it failed. I realized that that way of thinking was wrong as initially I thought of moving camera like this: lock your thumb(gyro's lookat) and index finger(initial"forward") and move them together. Now I realize it's more like two index fingers, independent from each other but still related. However this is further confusing me.

Now I think I should be doing the following:

Start() {

  1. get the gyro's lookat.

  2. get the initial forward and name it "forward" or something

}

Update() {

  1. get the gyro's new position and compare it to 1 to get a new rotation. then assign old lookat = new lookat.

  2. somehow convert it to a relative rotation on the game world => <<< lost here >>>

  3. applyl 2 to "forward" and update the camera using camera.lookat(forward) or something like that

}

More on 2 in update(). I am using LFR as in unity. So If i am looking down to start the game, my initial lookat is down(0, -1, 0), but my "forward" is (0, 0, 1). If I move my phone to the right, the gyro will think it's moving from down -> right(1, 0, 0) but my "forward" should also look at right(1, 0, 0). Now if I initially started the game holding my phone left(-1, 0, 0) then moved 90 degrees to right(at this point lookat would be looking at (0, 0, 1)), "forward" should be looking at right(1, 0, 0) after that rotation. Does this make sense?

Am I wrong in thinking that? Can anyone please shed some light on this issue? Quaternion is driving me crazy :( And I haven't even begun to think about applying the finger control...

I also asked this question on the forum if you don't have the definite answer but wanna discuss about it here: http://forum.unity3d.com/threads/129540-3D-camera-relatively-using-gyroscope-a-la-N.O.V.A.2 Thank you! :)

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image yetstay · Apr 06, 2012 at 11:32 PM 0
Share

So I've been fiddling with some stuff, and made a bit of progress, if not much. I made two game objects and applied gyro's rotation to the first one and saved the initial lookat Vector on the second one as the forward vector of that object, then found a rotation between those two objects then applied it on the camera. It's still buggy for some reason, and far from being completed but if anyone's interested here's a package file : http://www.bigupload.com/en/file/36474/iphonegyrocamtest.unitypackage.html If you don't have an iphone to build this on, you can still use the editor to see what I was trying to do.

This is working for the most of the part as far as detecting the starting position of gyro and applying camera accordingly so it will start looking at "front." However I find it beco$$anonymous$$g irregular after building a couple of times as the script doesn't detect the forward vector properly? However this is a start. If anyone's got any idea as to what's causing that, please let me know. I also need to work on saving the camera's lookat so when the game's paused and gyro's moved, the camera's still looking at the same position. Finger control can come after that.

avatar image resheez · Jul 16, 2013 at 11:51 AM 0
Share

yetstay... did you manage to find the solution??

avatar image Linearch · Oct 18, 2015 at 03:22 PM 0
Share

Yeah, I'd also like to know if you got a solution for this

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

3rd player orientation using gyro with offset 0 Answers

Virtual Reality - Android Gyroscopic Camera - Pitch and Roll Issues. 1 Answer

Camera X and Y velocity HELP! 0 Answers

Quaternion - Euler Angles, weird variable swapping when converting 2 Answers

"Free" rotation about a sphere 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges