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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Seated fixed position

Discussion in 'VR' started by ceradini, Aug 19, 2022.

  1. ceradini

    ceradini

    Joined:
    Aug 3, 2022
    Posts:
    3
    Hi at all,

    I need to implement in Unity a VR scenario (using the HTC Vive Pro headset) in which I have a humanoid avatar seated in front of a table, and this avatar should be allowed to move only the head based on the VR-headset movements. So the body should be fixed in the starting position, and the user can move only the head of the avatar for looking at the scene around him.

    For the integration of the headset I am using the Steam-VR plugin, which allows me to move correctly the head of the avatar accordingly to the movements of the headset. The main problem that I am facing is that if the starting position of the user is slightly different from the starting position of the calibration of the VR-headset, then also the avatar will move following the head (like if I stretch the avatar to a new position).

    My ideal goal will be to have a unity scene in which regardless of the starting position of the VR-headset (with respect to the calibration), the avatar will stay in the programmed position and the only movement allowed will be the one regarding the head. What should I use for implementing this scenario? Is there any tutorial/example/thread in which such a goal was achieved?

    Additional information:

    - unity version: 2019 (if really needed I can migrate to the 2020)
    - in addition to the Steam-VR plugin I am using the Inverse Kinematic plugin for implementing the kinematic on the humanoid avatar

    Thank you very much for your help.
     
  2. ceradini

    ceradini

    Joined:
    Aug 3, 2022
    Posts:
    3
    [Solution]

    The solution that I found working in my case (SteamVR + VRIK for kinematic) is to adjust at the start the position of the head target (the object that the head of the avatar will follow) to the same position of the camera. The script is something like the following:

    Code (CSharp):
    1. public GameObject headTarget;
    2. public GameObject VRcamera;
    3.  
    4. void Start()
    5. {
    6.      headTarget.transform.position = VRcamera.transform.position;
    7. }
    The head of the avatar will move to the exact location of the camera at the start, so it will be independent of the VR calibration position.
    To fix the avatar in the starting seated position you have to play with the weights of the VRIK.