Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 dornhege · Mar 27, 2017 at 08:17 PM · vrrotatescene-loading

What is the best way to align a roomscale VR scene to the headset position on load?

I have a multiscene game with a main scene and some portals into different rooms (scenes). What I want to achieve is that the player faces "north" upon loading a scene - regardless of where he is looking at in the real world.

Right now all scenes are loading "north" in respect to the PlayArea. But when a player looks "south" in the real world that is where he is facing upon starting in a new scene.

My next step would be to put the complete scene "architecture" in to an object and rotate it according to the player orientation on start. It seems a bit inelegant but if its the only way - how would my SceneArchitectureObject get only the horizontal player rotation? (I'm still learning C# and often miss the obvious)

(Using SteamVR, VRTK, TheLabRenderer)

Comment
Add comment · Show 1
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 dvandamme · Mar 28, 2017 at 12:25 AM 0
Share

the world has north and up and then the player has its own north and up. and what you want is for the world north and up to be dependent on the players local north and up. so yes, what you suggested with putting the world into an empty, rotating the empty to face the same as the player, is the only way force the player to 'look north' regardless of their real space orientation.

Which yes is a pretty blunt force fix.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Astiolo · Mar 28, 2017 at 04:11 AM

It's probably better to put the player object inside a container and move that instead of moving the rest of the scene. On startup you could get the initial rotation of the camera and set the rotation of the container to the inverse.

Comment
Add comment · Show 9 · 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
avatar image dvandamme · Mar 28, 2017 at 04:14 AM 0
Share

that doesn't work with vrtk. not sure about other vr frameworks, but the orientation of the head camera is always realitive to the real world setup

avatar image Astiolo dvandamme · Mar 28, 2017 at 04:19 AM 0
Share

I've never used VRT$$anonymous$$, everything I have used has worked with local coordinates. If there's no way of changing that, then the only other option is to move everything else (like you had said).

avatar image dvandamme Astiolo · Mar 28, 2017 at 04:29 AM 0
Share

thats very encouraging, which vr frameworks have you tried that allow this?

Show more comments
avatar image Astiolo dvandamme · Mar 28, 2017 at 05:30 AM 0
Share

I just played a little with VRT$$anonymous$$, looks to be quite usefull. It just ties in with the OVR Camera Rig from Oculus and I can just rotate that to get the effect that was asked for.

avatar image dvandamme Astiolo · Mar 28, 2017 at 05:39 AM 0
Share

on oculus its possible, but afaik vive makes real world rotation a constant that cant be altered. spinning the game world in relation to the player is the only solution. VRT$$anonymous$$ is THE best framework for doing anything in VR we've come across at my office - and we are always on the lookout...

avatar image dornhege · Mar 28, 2017 at 06:49 AM 0
Share

Hey guys - thank you both for your insights! So to summarize: If I use VRT$$anonymous$$ (at this point there is no way to go back) and develop for Vive - then the only way is to rotate the world (the scenes architecture) in relation to the player orientation.

Could you pass me a line of code for that? I did try but I always got the whole axis-set, so my world would rotate in the weirdest ways. (I am still new to coding)

And it still feels like there should be an easier solution ;)

avatar image dvandamme dornhege · Mar 28, 2017 at 09:17 AM 0
Share

'should' is always a fun word.....

something like

 public void RotateWorld()
 {
     // get all the objects
     Transform[] everything = FindObjectsOfType(typeof(Transform)) as Transform[];
     List<Transform> trimmed = new List<Transform>();
     // stick into a empty
     GameObject uberRotate = new GameObject("uberRotate");
 
     foreach(Transform item in everthing)
     {
         // if item has no parent, then its at the root of the scene, so will be parented to the rotator, otherwise left alone
         if(item.parent == null)
         {
             item.parent = uberRotate.transform;
             //trimmed is only the stuff you want
             trimmed.Add(item);
         }
     }
     
 
     // cull the player
     //  
     // you need to remove the VR stuff, and the player
     trimmed.Remove("player");
     trimmed.Remove("vrControllerObject"); // repeat for any root level vr thing, nothing else
     // 
     // 
 
 
     // rotate everything
     uberRotate.transform.eularAngles = new Vector3(uberRotate.transform.eularAngles.x, player.transform.y, uberRotate.transform.eularAngles.z);
 
     // drop all from null
     foreach(Transform item in trimmed)
     {
         item.parent = null;
     }
 
     // delete null
     Destroy(uberRotate);
 
 }

at a guess

avatar image dornhege · Mar 28, 2017 at 10:50 AM 0
Share

Thank you so much!

For now I had to take most of the clever part (where your script puts everything into an object and empties/destroys it after the rotation) out and do it manually. (there was some interference with scripts and objects that are already in my scene)

But it I am going to look into it and will try to make it work!

PS.: The mathematicians name was Euler not Eular ;)

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

[VR] VIVE controller press to load scene 0 Answers

Rotation stops when reload scene 1 Answer

rotate vr player 1 Answer

How to save position of stereo vrcameras 0 Answers

Camera rotation around player while following. 6 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