Search code examples
c#unity-game-enginevirtual-reality

VR gaze system from scratch, pointer didnt follow mobile "head"


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:

    myLine.SetPosition(0, transform.position);
    myLine.SetPosition(1, transform.position+(transform.forward*1000));

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, doesnt turn and move with the device.

What´s wrong?


Solution

  • Oh well... nevermind. I solve it. I needed a reference to the arCameraManager, it holds the head-tracking information.

    myLine.SetPosition(0, arCameraManager.transform.position);
    myLine.SetPosition(1, arCameraManager.transform.position+arCameraManager.transform.forward*100));
    

    o/