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.

World Anchor problem

Hi, i would like to ask you about a problem i'm encountering with world anchors. In the code below, i'm trying to load and attach a previously saved World Anchor, to a prefab i have loaded from resources in my Unity project.

WorldAnchor wa = this.store.Load(ids[index], prefab); Instantiate(wa.gameObject, wa.transform.position, wa.transform.rotation);

As i understood, world anchor locks an hologram to a specific position in the room, and is persistent, so that when i launch the app again, the hologram can be found in the same position in the room i have saved it.
The problem is, when i re-launch the app its position is relative to the Hololens device, which is considered the origin of the scene, so when i launch the app from a different position of the room, i find it in a different position too, but this is not as it should be with world anchors.
How can i lock it to an absolute position in the room ?
Thank you in advance.

Answers

  • Is the behaviour the same if you instantiate your prefab first and after that add the anchor to the gameobject?

  • @keljed said:
    Is the behaviour the same if you instantiate your prefab first and after that add the anchor to the gameobject?

    Unfortunately yes :-( That didn't solve the issue.

  • Hmm, the docu says:

    A WorldAnchor may not be locatable in the physical world at a point in time. If that occurs, Unity will not be updating the transform of the anchored object. This also can change while an app is running. Failure to handle the change in locatability will cause the object to not appear in the correct physical location in the world.
    To be notified about locatability changes:
    1. Subscribe to the OnTrackingChanged event
    2. Handle the event

    https://developer.microsoft.com/de-DE/windows/holographic/world_anchor_in_unity

    So maybe your anchor is not located, yet and you have to wait for the TrackingChanged event to relocate your gameobject/anchor.

Sign In or Register to comment.