Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.

WorldAnchor.OnTrackingChanged is not fired

Hallo,

I'm trying to share a world anchor between multiple HoloLenses, but I am already failing to locate an anchor, because the OnTrackingChanged event is not fired. I am using the code from the UNetAnchorManager from the MixedRealityToolkit for my HoloLens app.

`private void ExportAnchorAtPosition(Vector3 worldPos)
{
// Need to remove any anchor that is on the object before we can move the object.
WorldAnchor worldAnchor = ObjectToAnchor.GetComponent();
if (worldAnchor != null)
{
DestroyImmediate(worldAnchor);
}

        // Move the object to the specifid place
        ObjectToAnchor.transform.position = worldPos;

        // Attach a new anchor
        worldAnchor = ObjectToAnchor.AddComponent<WorldAnchor>();

        // Name the anchor
        exportingAnchorName = Guid.NewGuid().ToString();
        Debug.Log("preparing " + exportingAnchorName);

        // Register for on tracking changed in case the anchor isn't already located
        worldAnchor.OnTrackingChanged += WorldAnchor_OnTrackingChanged;

        SpatialMapping.DrawVisualMeshes = true;

        // And call our callback in line just in case it is already located.
        WorldAnchor_OnTrackingChanged(worldAnchor, worldAnchor.isLocated);
    }`

I'm using spatial mapping. When I walk all over the room the map is almost complete, but still no event is fired.

My Unity Version is 2017.1.2. on Windows 10 16299.

BTW, I am experiencing strange issues with the use of Singletons. Whenever I use a class that extends Singleton with Singleton.Instance I get a null value. It is because when I run the app on the device the Awake methods are not being called. When I run the app in the Unity Editor the method Awake gets called correctly. Maybe something is wrong with Unity?

Any help is appreciated!
Karim

Tagged:

Best Answer

  • keljedkeljed ✭✭
    edited November 2017 Answer ✓

    I'm using UNet because I have to communicate between HoloLens, PC and Android Smartphone.

    Meanwhile I was able to transfer the WorldAnchor to my server. The WorldAnchor of the cube gets only located after I move it and place it anywhere in the room. So I think that explains my original problem.

    BTW, the strange issue with the Awake method not being called has to to with adding the script to a NetworkBehaviour instead of a MonoBehaviour.

Answers

  • Is your Host HoloLens anchoring? Are both becoming the server? What is the Shared Anchor Text saying?

    AR Developer

  • I have a dedicated server running on a pc. The first HoloLens client creates the anchor and should sync it with the other HoloLens clients. But I don't want to sync the anchor until it is located. So it is not a network problem (,yet).

    I added a cube to my scene and attached the TapToPlace script to it. The WorldAnchor for this object is located correctly. I can use it for anchor sharing, but I thought it is perfectly adequate to have an empty game object to hold the reference WorldAnchor. Is that wrong?

  • dbarrettdbarrett ✭✭✭
    edited November 2017

    I honestly haven't tried running a dedicated server on another PC with the Sharing with Unet example. I always have one of my HoloLens host and the other HoloLens join as clients.

    Do you have your capabilities set in your player settings?

    As far as I know, the Sharing Folder in the MRTK is typically used for a dedicated server whereas SharingWithUnet is typically used for a HoloLens being the Host.

    AR Developer

  • keljedkeljed ✭✭
    edited November 2017 Answer ✓

    I'm using UNet because I have to communicate between HoloLens, PC and Android Smartphone.

    Meanwhile I was able to transfer the WorldAnchor to my server. The WorldAnchor of the cube gets only located after I move it and place it anywhere in the room. So I think that explains my original problem.

    BTW, the strange issue with the Awake method not being called has to to with adding the script to a NetworkBehaviour instead of a MonoBehaviour.

  • Like I said you should look into the Sharing folder instead of the SharingWithUnet folder to use multiple devices, the SharingWithUnet is specifically for HoloLens whereas Sharing is for multiple devices.

    This was taken from the Sharing Readme.txt in the MRTK:

    HoloToolkit.Sharing enables users to use multiple devices for a task by allowing the apps running on each device communicate and stay in sync seamlessly in real time.

    AR Developer

Sign In or Register to comment.