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 rainabba · Dec 17, 2014 at 12:30 PM · androidvr

Recenter or Reorient scene on Unity with Cardboard SDK

With Unity, the CardboardHead script is added to the main camera and that handles everything quite nicely, but I need to be able to "recenter" the view on demand and the only option I see so far is to rorate the entire scene and it seems like this is something the would address first-hand and I can't find anything in the docs.

With Oculus Mobile SDK (GearVR), it would be OVRCamera.ResetCameraPositionOrientation(Vector3.one, Vector3.zero, Vector3.up, Vector3.zero); though they handle it nicely each time the viewer is put on so it's rarely needed there.

P.S. Can't add a "topic" because I'm new? Good way to keep new user segments from being affective (or adopting) this system. "Google Cardboard"

Comment
Add comment · Show 2
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 SkaredCreations · Dec 17, 2014 at 12:32 PM 0
Share

You should put the code having issues in your topic, we cannot imagine what you're doing. PS: it's not that you "cannot add topic", just the topics from new users go under moderation until you get some "karma points" (that you get by questions and answers you post).

avatar image rainabba · Dec 17, 2014 at 06:19 PM 0
Share

I don't have any code. That's the point :) I'm looking for ideas. As I said, I could rotate the entire scene, but orienting the user is the first thing a VR app must do so it seems like something that should be handled nicely in the Cardboard SD$$anonymous$$ and I'd guess that I'm just not seeing it.

I COULD NOT create a new topic. Literally, it said that I need 50 points to create a new topic.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by ksVPN · Feb 12, 2015 at 03:52 PM

I asked this question the other day without seeing your question. I did something that worked for me and maybe it'll help you and others. I'll mention it here and on my own question for future searchers.

My biggest problem was that Cardbaord.SDK.HeadRotation is read-only and it's a Quaternion that is stuck in 3D space and can't be manipulated like you want. So instead of using the Cardboard.SDK.HeadRotation to directly control your camera game object's position, I calculated the change in rotation between updates and applied that rotation to my camera game object.

I'm very new to this and I'm writing this example code off the top of my head, so there may be errors, but it's close to what I've implemented that is working.

 //used to set a game-object, such as a parent, as a point reference for resetting view
 public Transform target;
 private Quaternion prevRotation;
 
 void Start () {
     //set your first rotation as starting head rotation
     prevRotation = Cardboard.SDK.HeadRotation;
 
 }
 
 void Update () {
     //on button push
     if (Input.GetButton ("Reset")) {
         //doesn't have to reset to target, can reset to anything you need
         //such as Quaternion.identity
         transform.rotation = target.rotation;
 
     } else {
     
         //here you set the the rotation to the difference between the current head
         //rotation and your previous head rotation
         var rot = Quaternion.Euler (Cardboard.SDK.HeadRotation.eulerAngles
                         - prevRotation.eulerAngles);
 
         //add this difference to current rotation by using the Quaternion operator '*'
         transform.rotation *= rot;
 
     }
 
     //save the current head rotation as prevRotation to be used next update
     prevRotation = Cardboard.SDK.HeadRotation;
 
 }

Please note I'm new to unity and programming in general, but this is currently working for the game I made, so I hope it helps!

Comment
Add comment · Share
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

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

A node in a childnode? 1 Answer

Unity + Android + Development Build = CompareBaseObjectsInternal can only be called from the main thread. 1 Answer

Cardboard black screen on launch 0 Answers

APK Can't be open in Android system microphone 0 Answers

How may I reduce memory usage for playing video? 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