Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

HTC Vive Pro camera transformation

Discussion in 'Scripting' started by maryamk, Jan 27, 2020.

  1. maryamk

    maryamk

    Joined:
    Apr 4, 2017
    Posts:
    18
    Hello!

    Working with HTC Vive Pro and Unity, I am trying to rotate the camera (the viewpoint of the user) some time while the user is using the headset.
    I have tried putting this in my Update() function:

    Code (CSharp):
    1.  
    2. public Camera cam1;
    3.  
    4. Update()
    5. {
    6. ...
    7. if( /* some condition */ )
    8. {
    9.   cam1.transform.Rotate(0, 0, 5);
    10.  //or
    11.   cam1.transform.Rotate(0, 0, 5);
    12. ...
    13. }
    14.  
    I attach this to a GameObject in the scene, and for Cam1 I drag the CameraRig and attach it to the cam1 parameter of the script.

    I am aware of what this might cause. This is part of an experiment I am doing and the number and axis above are just an example.

    However, the camera does not move at all.
    First I was using the Main Camera but I deleted that and put the CameraRig prefab from SteamVR in my scene.

    Any ideas please?
    thanks
     
    Last edited: Jan 27, 2020
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,186
    I'm pretty certain you can't rotate the camera directly as it's tied to the device. I think if the camera is a child of something, you can rotate the parent. However, in VR, rotating the characters head can create a odd and sometimes sickening experience, so I would caution against forced rotation.
     
    maryamk likes this.
  3. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    First of all, please don't. Rotating a VR player's camera is far and away the most nausea-inducing thing you can possibly do to a VR player. Even players who have their VR legs will find themselves dizzy very quickly. Worse, you seem to be attempting to rotate it on the Z axis?! Tilting the camera is the worst possible way to rotate the player. What you are doing here seems to be the perfect recipe to make players fall over and/or vomit.

    There's also no context here. We have no idea what "cam1" is. If it's literally the object with the Camera component, then the VR plugin overrides that position immediately with the user's actual rotation.

    So we're gonna need more context in order to know how to be able to help you. And, personally, I will need to know what you're actually intending to do with this before I'd be *willing* to help you, because with few exceptions this is a Very Bad Bad Thing (TM).
     
    maryamk likes this.
  4. maryamk

    maryamk

    Joined:
    Apr 4, 2017
    Posts:
    18
    Thanks, I edited my main question to make it more clear.
    And I am aware of effects rotating the user's viewpoint has, these axis and values are just examples. I'm designing an experiment to test some perceptual visual feature.
     
  5. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,186
    And as both of us mentioned, the headset overrides the camera, so any attempt to move it directly will fail.
     
  6. maryamk

    maryamk

    Joined:
    Apr 4, 2017
    Posts:
    18
    Thanks, Yes that's why I haven't been able to do it yet. But i know others have done it with Vive or other headsets and I'm quite sure there is a way to manipulate the camera at some point through scripts
     
    Last edited: Jan 27, 2020
  7. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,186
    Yes, you make it a child and rotate the parent.