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.
Options

Position Independent Object Placement

Hey all,

this is kind of a follow-up question to what has been discussed here:
https://forums.hololens.com/discussion/1162/holograms-230-chapter-1-no-room-mesh-displayed

There, user ahilier says "As David mentions above, the SRMesh should only load while in the Unity Editor. [...] The coordinates (0,0,0) is the location of the camera (HoloLens) when the application first launches. This will be considered the center of the holographic world."

I understand that. But then, how can I place 3D Objects in my scene independent of the position the user is in when he/she launches the app.
For example, say I want to display an object on some table in my room. I want this object to be at the exact same position (on the table) no matter where i currently am in the room when I launch the app.

So basically, I want to do the same thing as Microsofts "Holograms" app does on the "main menu" screen of the Hololens.

Can anyone help?

Thanks, Kev

Best Answer

Answers

  • Options

    I tried the script above but for some reason, WorldAnchorStore.GetAsync is not calling the callback function.

    WorldAnchorManager.cs attached to an active game object:

    using UnityEngine;
    using UnityEngine.VR.WSA.Persistence;
    using System.Collections.Generic;
    using UnityEngine.VR.WSA;
    
    namespace HoloToolkit.Unity
    {
        public class WorldAnchorManager : Singleton<WorldAnchorManager>
        {
            // removed some lines from original script
            public WorldAnchorStore AnchorStore { get; private set; }
    
            void Awake()
            {
                Debug.Log("awake");
                AnchorStore = null;
                WorldAnchorStore.GetAsync(AnchorStoreReady);
            }
    
            private void AnchorStoreReady(WorldAnchorStore Store)
            {
                Debug.Log("Anchor store ready");
                AnchorStore = Store;
            }
       }
    }
    

    Debug says:
    awake

  • Options

    Okay problem is solved, the GetAsync callback is not called in the unity editor. I can now save and reload at runtime instantiated GOs at their correct position. Thanks for the help.

  • Options

    Great answers!
    What i am trying to do, without any luck so far, is to have multiple objects in a scene and TapToPlace each object at a position in the room. My problem is that, owing to the WorldAnchor (from HoloToolkit) that i attach to each object, when i start the app all objects appear at (0, 0, 0). So i get around 20 objects appearing one on top of the other...
    Is there a way to add persistence to my objects and have them appearing at separate (predefined) positions when i start the app?

  • Options

    @mdouk said:
    Great answers!
    What i am trying to do, without any luck so far, is to have multiple objects in a scene and TapToPlace each object at a position in the room. My problem is that, owing to the WorldAnchor (from HoloToolkit) that i attach to each object, when i start the app all objects appear at (0, 0, 0). So i get around 20 objects appearing one on top of the other...
    Is there a way to add persistence to my objects and have them appearing at separate (predefined) positions when i start the app?

    I found a solution for anyone having the same problem...
    For every object that has the TapToPlace script attached, I went to the Hierarchy/TapToPlace component and under the SavedAnchorFriendlyName variable I typed the name of the game object (any unique name will also work I guess).

Sign In or Register to comment.