- Home /
Align room to player at beginning in steam VR
Hey, I am using Unity and Steam VR to run psychological experiment.
I have a big testing room and I want to position the player in that room and want to align the whole scene relative to the player. So for instance, what ever the position of the player in the physical world is at beginning is the middle of the virtual world. Can someone point me in the right direction to do this?
Just spawn your player at 0, 0, 0 every time? Or teleport him there when the game starts
It is not enough because when I start the build, the camera starts in a particular spot in my virtual environment. When I manually move the H$$anonymous$$D let's say two metres, then the camera also starts in a different spot in the virtual world. What I want though is that the camera starts in the same spot in the virtual world regardless where it is in the physical room (i.e. relative to the sensors).
I tried to change the transform position as soon as the build starts but it doesn't seem to work.
player.transform.position = new Vector3(1.91f, 0.19f, -3.7f); // start position
Answer by Vonni · Oct 05, 2018 at 03:53 PM
I will assume that your camera rig (the root object for the VR system is in center).
Now when the game starts. You need to get the position of the players head, the tracked position of the googles. Now get the orientation of the googles. Flatten the orientation as you only want the Y rotation. Also floor the position. Now apply the negative values to your main root gameobject.
Your answer
Follow this Question
Related Questions
Unity 2018 Steam VR compiling issue 1 Answer
Steam VR not playing in editor 1 Answer
SteamVR : How to get the transform of controller ? 1 Answer
Preparing the build for HTC Vive 1 Answer