Hello everyone.

We have decided to phase out the Mixed Reality Forums over the next few months in favor of other ways to connect with us.

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.

The plan between now and the beginning of May is to clean up old, unanswered questions that are no longer relevant. The forums will remain open and usable.

On May 1st we will be locking the forums to new posts and replies. They will remain available for another three months for the purposes of searching them, and then they will be closed altogether on August 1st.

So, where does that leave our awesome community to ask questions? Well, there are a few places we want to engage with you. 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. 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.