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.

Has anyone ever had success at creating WorldAnchor points?

I have had no success at adding a WorldAnchor component to a GameObject that worked for the HoloLens Emulator. For instance this code snippet:-

    static public GameObject create_sphere(Vector3 pos)
        var m = GameObject.CreatePrimitive(PrimitiveType.Sphere);
        var rigidbody = m.AddComponent<Rigidbody>();
        if (pos!=Vector3.zero)m.transform.position = pos;

        WorldAnchor anchor = null;

        anchor = m.AddComponent<WorldAnchor>();//ALWAYS RETURNS NULL !
        if(anchor !=null)
            addcomment.comment = "added world anchor";
                //anchor is located
                addcomment.comment = "world anchor is located";
            addcomment.comment = "not added worldanchor";

        rigidbody.velocity = Vector3.zero;
        rigidbody.constraints = RigidbodyConstraints.FreezeAll;
        return m;

creates spheres on the triangulated background fake mesh like in the following clip:

As you can see the spheres are created but I failed in every instance to create a WorldAnchor associated with each one of them. I have also set up a WorldAnchorStore but of course it does not effect this problem.

I would like to hear from anyone who has had any success in creating WorldAnchors and if there was anything special you had to do.

Best Answer


  • Alec_HAlec_H ✭✭
    edited July 2016

    @wheelchairman Your assignment of an anchor is setting it to null and is not creating a non null anchor.
    WorldAnchor anchor = gameObject.AddComponent();
    That is how you should be using world anchor as referenced here.

  • AlexDAlexD ✭✭✭

    @wheelchairman please don't open the same question in 3 different places. I've answered the one in Discussion but this is causing unnecessary clutter on the forums.

    Maybe a mod (@Patrick, @ahillier @neerajwadhwa ) can close and consolidate the threads. Thanks.

  • I'll try not to clutter up the forums, I just wanted an answer and it still is elusive. I shall keep to the Discussion Forum for the topic from now on - Sorry

  • AlexDAlexD ✭✭✭

    did you at least see my proper answer in one of your topics ? I think that would help you

  • Sorry AlexD I answered it in the Discussion forum. Even commenting out all the RigidBody component references did not give me a resolution to this problem. I still need to be convinced the WorldAnchor component addtion works properly.

     anchor = m.AddComponent<WorldAnchor>();

    This program line does not return and it looks like perhaps there might be a stack or a thread problem with it. Have you an example you could show me where adding this component works? I would be delighted to try it. Thanks for bearing with me I do appreciate it.

Sign In or Register to comment.