Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Disable position tracking (Y axis) for VR? For a flight sim like, seated cam setup

Discussion in 'AR/VR (XR) Discussion' started by rpg_gamer, Feb 28, 2018.

  1. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    Hi there, I have a question about VR cameras in the context of setting one up that doesn't follow position tracking, or has a set Y distance that the players "head" or camera should be at.

    Trying to get a cam stationary (except for head tracking) for an in cockpit view for a flight test. The problem I'm having is that when i start my scene, the camera is always offset to the height I am standing or sitting, and I can walk around straight out of my cockpit model.

    I'd like to be able to look around my cockpit, but of course not be able to stand up, or walk out of the cockpit if I stand up or walk around in my room.

    How do I disable that when having VR enabled in unity? I am using a windows mixed reality headset. and just a normal unity camera setup (not steamvr), with vr enabled in the player settings.

    I have tried (in inspector on the camera while scene is running) resetting the position of the camera to 0, and it will not do that. The Y position of the camera is always at 1.6 or so sitting, higher standing.


    How do I set this camera up for a seated vr experience, where you are not going to want to stand up, or walk.. I am going to want to look around and pan my head in and out of course. I just don't want the camera to be able to leave the bounds of the cockpit, and be able to get that camera height re centered to where eye height should be ( I have the camera childed to a game object set at the proper position I want the camera to be at, but always appears 1.6 above it)
     
    Last edited: Feb 28, 2018
  2. RadialGames

    RadialGames

    Joined:
    Jan 31, 2017
    Posts:
    11
    I think what you want is:

    Code (csharp):
    1. UnityEngine.XR.InputTracking.disablePositionalTracking = true;
    (there is also a .disableRotationalTracking bool in there)

    However! Players will definitely want to "lean" in their seat to get a better view out a cockpit window or to get closer to the instruments or something, you probably don't actually want to disable positional tracking. It also feels really bad if you put in an "invisible wall" that prevents the camera from moving outside the cockpit.

    I strongly recommend something like fading the camera out (just fade to black) if you exceed a certain distance from the chair. this gives the player full freedom to move how they wish, but prevents them from "cheating" out of the cockpit. I believe this is the approach Star Trek Bridge Crew uses (though I think they're a bit too aggressive on the distance).
     
  3. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214

    AAhh. So my one question is then, how do I start my scene with the camera in the correct position, (inside of the cockpit), instead of floating above the desired head position? I have the camera set where I want it, but every time I start the scene I am floating above the cockpit.
     
  4. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    what I need to do is somehow override the the centering that the windows MR home creates, and keep the camera at my desired position.
     
  5. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    522
    You first need to find the headset position within the play space, and find the difference between that and the default cockpit position, and translate the playspace in your game world by the opposite amount. Now the headset lines up with the default position. Add a controller button to do this called "recenter camera" or similar. This offset puts the headset at the desired location (within the cockpit coordinate system of course).

    You probably want to leave positional tracking working 100% inside the cockpit area, so the player can move their head around a little bit and look around (looking involves small translations). The problem appears when they go too far and intersect the cockpit. In that case, you detect the collision between the cockpit geometry and headset, and translate the playspace offset calculated at the start in the other direction. so from the headset point of view as soon as your head hits the side of the cockpit, and you continue, you push the whole cockpit (and your head remains just touching the side). similarly you return things towards normal as the headset comes back into the permissable zone (this is trickier to get right, but not impossible).

    Look at Il2-bos and Climbey for examples of this in action. BoS does it in a somewhat flaky manner, and is probably not a great example of how to do it, as they have errors in their implementation. You can definitely do better, but it is a cockpit game at least. Climbey is a much better system, but its more room scale. As you walk into or put your head into a wall, you get translated backwards. when you stop the motion, you are left standing there, there is no return to center (which works ok with climbeys locomotion but not in cockpit case),. You'll have to translate headset back towards the center while maintaining the contact with the wall.

    The crappiest implementation of all is Star Trek Bridge Crew, it just blacks out the camera if you move too far. This is rather annoying, but avoids all unpleasant sickness-inducing effects associated with translating the headset. Probably should allow this as an option.

    If you disable positional tracking totally, it feels very weird, as even turning your head involves positional changes (my vive headset cameras locations are not the center of rotation when i turn my head). It's a subtle but sickening effect. BoS has issues with this, as if you move your chin to your chest, you can notice the cockpit shift itself up/down slightly, and its really annoying. Better to allow free movement as much as possible inside the cockpit, and only shift the headset when it tries to leave the cockpit area.
     
    Last edited: Mar 6, 2018
    elhongo likes this.