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.

Loaded WorldAnchor not really anchored correctly

sebseb
edited February 2018 in Questions And Answers

I have a Unity project where I have two scenes. In the first scene I use TapToPlace in MixedRealityToolkit to place an object which is is also the WorldAnchor. I also save this object to the WorldAnchorStore. In the second scene I load this anchor (which seems to succeed btw). Thing is the GameObject I'm trying to add the anchor to always displays where I happen to point my head at the start. It doesn't anchor in the same place as in the first scene.

What could I be doing wrong here? The object I'm passing to the WorldAnchorStore.Load function is supposed to be my root object. It is like it is not even trying to match and find the correct spot when loading the second scene.

Edit: the Anchor does load and it reports to be located but it is in the wrong place. The Anchor GameObject is the root object and I have checked every child. I have no idea what the error could be?

Tagged:

Best Answer

  • sebseb
    Answer ✓

    OK I feel a bit stupid now. Apparently my Hololens camera had moved and was not in 0,0,0. This messed up everything pretty hard. I would have thought that stuff would just be off by a little but apparently it makes anchoring not work at all. So thats was a new for me.

Answers

  • Have you tried doing something like DontDestroyOnLoad(gameObject) ? Your object will then persist through scene changes.

    AR Developer

  • Well I forgot to say that the anchor is also transferred to other devices. That part seems to work (export, sending, import). I just work on one device now to make sure it works there before trying with multiple devices. I'm sure DontDestroyOnLoad would work fine locally but this is a shared experience and hence I want to save and load from the WorldAnchorStore. by all means it should work, and it has worked before. It is just now that it doesnt seem to any more. Not sure what I'm doing wrong because log output says it has saved and loaded the anchor just fine. But it doesnt "stick" to the same place but rather where I'm looking when the scene loads. I'm sure it is something minor that I'm missing though.

    Sharing is done with a custom server just distributing the WorldAnchor to clients. Not using the Shared Service thingy.

  • Ahhh, I see. So whenever you save the anchor and load the next scene is it in front of you? I only say this because, what could be happening is when you are loading another scene your 0,0,0 point is changing to wherever you start your next scene at. So whenever you load the next scene it puts the anchor relative to where it was to the origin, if that makes sense.

    Or you could also check the WorldAnchorManager, I believe if you recently upgraded your MRTK and there is now an option for if you want persistent World Anchors or not. If that is not checked then your world anchors may not keep all of their information when changing scenes.

    I haven't worked a lot with multiplayer on external servers, I tend to stick with the SharingWithUnet stuff. So I'm sorry if I'm not much help

    AR Developer

  • Yes, it is something like that. What I dont get is why it all of the sudden started to act like this. It should place it relative to the room mesh right?

  • I should say that while in the initial scene the object is indeed stuck to the real world. It is when reloading this anchor in another scene that it doesn't seem to work.

  • Have you checked the other clients to see if it loads in the updated spot or in the original spot? So maybe start it with one and then connect it to it and try and get that anchor with another and see where it places the anchor on the second client.

    AR Developer

  • sebseb
    edited February 2018

    I have, that is how I noticed that stuff doesn't work. Then I checked on just one device and the same thing happens. I can only describe it as you said; the transform is indeed sent but it is positioned relative to it's own coordinate system rather than relative to the room.

    I guess what I'm saying is that I as a programmer dont really have any say in that. I attach the world anchor and it should override the transform of the parent. Is this a bug in Unity?

    I'm using Unity 2017.3.0f3 btw.

  • Is your anchor store persisting through the scene changes?

    AR Developer

  • Yes, well the Anchor Store is a singelton type thing. Also it does indeed load the anchor. It just doesn't stick it to the correct place. Very weird... I'm downgrading to 2017.2 now to see if that helps.

  • Are you getting anything from your log?

    AR Developer

  • From TapToPlace I get that the anchor has been saved. When loading it I get that is has been loaded. Not much more I can do really...

  • Have you checked the Show Detailed Logs bool under the World Anchor Manager script?

    AR Developer

  • @dbarrett said:
    Have you checked the Show Detailed Logs bool under the World Anchor Manager script?

    Yes

  • Is the name of your anchor spelled the same in saving and then later loading? Other than that I really don't have anything else that I can think of to check without the project in front of me.

    AR Developer

  • @dbarrett said:
    Is the name of your anchor spelled the same in saving and then later loading? Other than that I really don't have anything else that I can think of to check without the project in front of me.

    It is a client project so I cant really share it. I have no idea either actually. I mean everything points to "working" but it does not.

  • So I have printed out the isLocated variable and it says "true". Although the anchor is not at all in the place it should be. Has anyone seen this weird behaviour before?

    I'm now using 2017.2 and latest MRTK from repo.

  • sebseb
    Answer ✓

    OK I feel a bit stupid now. Apparently my Hololens camera had moved and was not in 0,0,0. This messed up everything pretty hard. I would have thought that stuff would just be off by a little but apparently it makes anchoring not work at all. So thats was a new for me.

Sign In or Register to comment.