Search Unity

[ AR Foundation ] ScreenPointToRay is laggy on AR Session camera

Discussion in 'AR' started by thePostFuturistUnity, Feb 24, 2020.

  1. thePostFuturistUnity

    thePostFuturistUnity

    Joined:
    Nov 16, 2012
    Posts:
    53
    Hello,

    I'm using the ScreenPointToRay function to cast a ray from a position on screen to a 3D object, and then using LineRenderer to draw a line between those two objects.

    In the AR Session camera, when I move the phone, the LineRenderer drawing doesn't update fast enough and lags. In my case, I have a RectTransform with an Image, to the center pivot of which the LineRenderer receives its first point ( the second is the 3D object ). The Line Position 0 is behind the Image, but due to the lag, the origin appears outside the Image.

    Furthermore, applying this same technique in regular 3D Space, or Vuforia Model Tracking does not lag.

    I'm setting positions via SetPositions, and tried running this in Update and LateUpdate with no resolve.