Search Unity

How to disable parent transform affecting camera position/rotation

Discussion in 'AR/VR (XR) Discussion' started by Hannibalov, Oct 9, 2015.

  1. Hannibalov

    Hannibalov

    Joined:
    Aug 8, 2012
    Posts:
    6
    Hi, right now if you parent a VR camera then the position and orientation of that camera are affected by that of the parent. The problem rises, though, when you want to move an avatar's head in sync with the tracking and have a camera in first person perspective. Then you can't set the avatar's head to be the camera's parent because if the real head moves x units then the avatar's head moves x units and the automatic VR camera displacement moves another x units. The result is your perspective moving 2x units! This is true for rotations too, which is even worse.

    One solution is not to parent the camera to the avatar. That becomes cumbersome when you want to move the avatar around, because you need to sync the 2 objects etc.

    Another solution could be that the camera didn't magically move without developers' control, if so specified.

    Is there any chance the unity guys could implement some api to restrict what affects the camera?
     
  2. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Actually I think parenting the camera to the avatar sounds like asking for trouble.

    What I'd do is keep camera and avatar separate (could be children of a common parent for both but not children of each other). If you have room-scale tracking, you'll actually want the camera to be what controls the avatar's position, so you could sync from the camera to the avatar's head. If you don't have room-scale tracking, you're in trouble anyways ... but even if you have any kind of positional tracking, you'll still want the head of the player (i.e. the headset, i.e. the camera) be moved by that positional tracking, not the other way round.

    If you really don't have positional tracking, you'll probably not want the head of the player to move because that's what makes quite a few people sick.

    All that said: Unless the avatar is heavily simplified (just a head, or head and two floating heads in case you have motion tracked controllers), you'll need full body motion tracking anyways to prevent players feeling really weird about the avatar body that doesn't behave like their actual body.
     
  3. Hannibalov

    Hannibalov

    Joined:
    Aug 8, 2012
    Posts:
    6
    Hi, I appreciate your time to reply. Here are my comments:

    "What I'd do is keep camera and avatar separate"
    That's exactly what I do, it's the first solution I proposed. But that is not optimal since you have to always sync camera and head. Also when you are developing a highly dynamic scene (with avatars and cameras created and destroyed in runtime), with scripts that depend on the existence of both etc. the chances of getting bugs are high.

    "[...] the head of the player be moved by that positional tracking, not the other way round"
    That's also exactly what I do at the moment. I use a sensor fusion with IK and trackings from the HMD and full body tracking systems. That, however, is a separate problem. Updating my avatar correctly is a problem I have solved a long time ago, now I just need the cameras to be fixed with respect to the head (which by the way is working for every VR camera approach I've developed except for unity's native VR support because the cameras move without my control)

    "[...] you'll need full body motion tracking anyways "
    I do have those. In fact, you can check a summary of what I have here:
    . The video is a bit old, we have a few more devices now.
     
    jashan likes this.
  4. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    That looks pretty cool. And I agree that Unity native VR solution has a rather questionable design (that doesn't really let you do things "the Unity way" using components to add functionalities to game objects ... which I found weird right from the start). In fact, I have created a Unity Feedback entry hoping that they'll improve it:

    For the time being, I'm using the SteamVR Plugin from Valve. This may not be as well integrated into the engine as the native integration ... but I find it much more "Unity-like" from how it was designed.