Search Unity

How to freeze rotation and transform from HMD's children

Discussion in 'AR/VR (XR) Discussion' started by kariyann, Sep 14, 2018.

  1. kariyann

    kariyann

    Joined:
    Dec 28, 2013
    Posts:
    2
    Hello everybody,

    I'm currently working on a game overlay project.
    I've a VR aircraft game using SteamVR to provide its VR experience. I would like to create an custom cockpit Overlay to interact with. I use the BenotterOVRlay (link). This overlay doesn't allow me to set my project as XR/VR but I can get my project to work properly.

    Unfortunetaly, when I launch my aircraft game, it transform my HMD position and rotation. And it result in a non centered overlay regarding to the aircraft cockpit.
    So I set all my overlays as HMD children in order to get their positions set relative to the HMD when I start, and I tried to freeze the rotation and transform of all my cockpit's overlays objects using this code :

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class RotFreeze : MonoBehaviour {
    6.     Quaternion rotation;
    7.     Vector3 position;
    8.     // Use this for initialization
    9.     void Start () {
    10.      
    11.         rotation = transform.rotation;
    12.         position = transform.position;
    13.     }
    14.  
    15.     // Update is called once per frame
    16.     void Update () {
    17.         transform.rotation = rotation;
    18.         transform.position = position;
    19.     }
    20. }
    But this doesn't seem to work, overlays are statics but they're not centered.
    Can somebody give me advise about this ?

    Thanks