Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Canvas Ui tracking AR object lag

Discussion in 'AR' started by kingbaggot, May 23, 2020.

  1. kingbaggot

    kingbaggot

    Joined:
    Jun 6, 2013
    Posts:
    51
    Here's a video with my issue - watch those yellow/blue numbered canvas circles wobble around trying to catch up with the AR painting.

    https://drive.google.com/file/d/1QjaG5w0F_wzo8EsA17T_XF_AtcRrRcKR/view?usp=sharing

    I'm reading my 3d objects positioning and coverting them like this - where pso is an AR object and the debugCanvas is the UI canvas with the UI stuff.

    float sx = debugCanvas.GetComponent<RectTransform>().rect.width * cam.WorldToViewportPoint(pso.transform.position).x;
    float sy = debugCanvas.GetComponent<RectTransform>().rect.height * cam.WorldToViewportPoint(pso.transform.position).y;

    i then set my ui canvas objects like this - this canvas object is anchored bottom left so it matches the viewport points which track from bottom left, across and up.
    myRt.anchoredPosition = new Vector2(sx,sy);

    now this works ok - everything is in the correct position, BUT it has some lag, so if I wave the camera around, the ui objects take a second to catch up with the AR object.

    Not sure if this is something fixable or not, but any pointers would be appreciated
     
  2. forteller

    forteller

    Joined:
    Jun 15, 2019
    Posts:
    54
    I might try experimenting with different "Update Types" on the Tracked Pose Driver component. Especially on Android I heard changing this setting might reduce jitteriness as the native camera refresh rate and Unity will be more closely synced.