- Home /
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)
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.
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.
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
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).
thats very encouraging, which vr frameworks have you tried that allow this?
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.
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...
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 ;)
'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
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
![](https://koobas.hobune.stream/wayback/20220612114003im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
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