Search Unity

Question How to get access to and script with the tracked Vuforia Multi-target position?

Discussion in 'AR' started by DanieliAndrea, Oct 20, 2021.

  1. DanieliAndrea

    DanieliAndrea

    Joined:
    Oct 19, 2021
    Posts:
    2
    Hi! I'm quite new in using Unity. I'm developing an AR application for HoloLens V2 (using MRTK and Vuforia). The application expects 2 multi-targets, I'll call them M1 and M2. M1 is used to stably visualize a cube in a target position, I'll call it CubeHologram and it is assigned in the hierarchy as a child of M1. Via script I want to position CubeHologram once (when a button is pushed) at the target position that is the tracked position of M2 plus a Vector3, I'll call this vector as Displacement. Moreover, the app expects the calculation of the delta between the 3 coordinates of the CubeHologram and the ones of the tracked M2 and to use these delta values to manage some functionalities of the app.


    I've tried to use these lines of code:
    [...]
    public GameObject M2;
    public GameObject CubeHologram;
    public Vector3 Displacement; % given in mm by the user
    private bool firstframe = true;
    [....]
    [...]
    if (firstframe){
    CubeHologram.transform.position.x = M2.transform.position.x + Displacement.x/1000;
    firstframe = false;
    }
    [...]
    deltaX = (CubeHologram.transform.position.x - M2.transform.position.x)/1000; % delta value then is displayed in mm
    [....]


    The script does not return any error. M2 can be assigned from the Unity scene as input of the script. The CubeHolgoram is correctly created but then it oscillates even when M1 is not moving (i.e. the user moves the head or even when he/she tries to stably look at M1) as well as the deltaX values are not stable even under the same condition (M1 not moving and user moving head or even stably looking at M1).

    It may be relevant that, as it can be seen from the script, I'm working in the millimetres order, thus, deltaX and CubeHologram oscillate within the millimetres order (even until 10 mm of oscillation). Moreover, it might be relevant the fact that CubeHologram holds a material that is transparent (A-channel = 125) and I say that because while CubeHologram oscillates in the scene the other virtual contents (that hold opaque material) seem more stable.

    I would have some suggestions to solve these problems. I don't know if it may exist a more appropriate manner of scripting multi-targets and get access to their position that can result even in their more stable visualization or if there are some options in the Project Settings or in the Main Camera or something similar that can be adjusted to improve the stabiltiy of my app.

    Thanks anyone!
     
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,822
    Hello there! Vuforia support is handled directly by them. In case no one can help here, you can also report your issues and questions to Vuforia's forums and their team will help address.
     
  3. DanieliAndrea

    DanieliAndrea

    Joined:
    Oct 19, 2021
    Posts:
    2
    I'll try to post also there! Thank you for the suggestion