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’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

Question Unity Vuforia object looking at camera issue

Discussion in 'AR/VR (XR) Discussion' started by Renzzauw, Sep 9, 2020.

  1. Renzzauw

    Renzzauw

    Joined:
    Oct 7, 2015
    Posts:
    3
    Program description
    I'm working on an AR application using the Vuforia framework where I have objects related to biological concepts which have been made more appealing to children by adding faces to these objects that always look at the main camera. These faces are in a separate layer and are rendered on top of all the other layers. This face consists of a quad with an unlit material containing the face sprite. The face object is a child object of the main biological object and is put at the origin of its parent (localPosition = {0,0,0}) See example here:

    Code
    To make sure the face looks at the camera and is always oriented upwards with respect to the camera up vector, the following code is executed.

    Code (CSharp):
    1.  
    2. public class Face : MonoBehaviour
    3. {
    4.    private Camera mainCamera;
    5.  
    6.    private void Awake() => mainCamera = Camera.main;
    7.  
    8.    // ...
    9.  
    10.    private void Update() => transform.rotation = Quaternion.LookRotation(transform.position - mainCamera.transform.position, mainCamera.transform.up);
    11. }
    My ARCamera (base & main camera) renders all layers except for the Face layer. This layer is rendered by an additional stacked overlay FaceCamera, which is a child of the main camera.

    Issue
    This seems to work properly in the editor and play mode, but for some reason when the game is build to an actual mobile device (only tested it on android phones so far, so I'm not sure what the behaviour is on other devices), the faces seem to be offset from the origin of their parent when it comes to the position, instead of being exactly at the origin.

    I have no clue what is causing this, but I suspect it has something to do with either the camera settings or an incorrect Vuforia setting. I have provided additional screenshots of my current setup below. ARCamera, FaceCamera and Vuforia Configuration.




    A video capture of my issue can be seen Here. Here you can see that the faces kind of "hover" above the projectiles instead of being at the center. This behaviour is especially visible when they just spawn in at the edges of the screen.

    I hope somebody knows the issue I'm facing here. Thanks in advance!