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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

VR gaze system from scratch, pointer didnt follow mobile “head”

Discussion in 'VR' started by clebertavares, Nov 19, 2019.

  1. clebertavares

    clebertavares

    Joined:
    Jan 2, 2012
    Posts:
    55
    Hello,

    I started to make a simple VR gaze system from scratch, using Unity ARFoundation. First thing was to draw a line from my point of view to "infinity", like a pointer. I have this script running on my AR Session Origin at Update:

    Code (CSharp):
    1.  
    2.     myLineRenderer.SetPosition(0, transform.position);
    3.     myLineRenderer.SetPosition(1, transform.position+(transform.forward*1000));
    4.  
    This works on editor, I have a line, and I can turn and move my session origin (my "head" with camera), it follows up.

    But, when I use it on mobile... the line keeps still (it shows up), doesnt turn and move with the device.

    Here´s my setup:

    https://ibb.co/NtrQK9L

    I have defaults AR Session and Session Origin, because I will be creating AR objects (I do that in another scene too, its working, this one its another scene with two cams for vr, two canvas and so on). In one of the cams I disable the Pose Driver to avoid conflicts, but even enable (or the other components) its not working.

    What´s wrong?
     
  2. clebertavares

    clebertavares

    Joined:
    Jan 2, 2012
    Posts:
    55
    Oh well... nevermind. I solve it. I needed a reference to the arCameraManager, it holds the head-tracking information.

    Code (CSharp):
    1.  
    2.     myLine.SetPosition(0, arCameraManager.transform.position);
    3.     myLine.SetPosition(1, arCameraManager.transform.position+arCameraManager.transform.forward*100));
    4.  
    o/