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.

Get the minimal distance to the walls

Hello, I'm discovering the spatial mapping/understanding and I'm trying to get the position of the nearest wall in order to be sure that an hologram is in the same room as the user.
I read most of the script and wrote this code.
void CheckPlanes() { float minDist = 1000f; List<GameObject> walls = SurfaceMeshesToPlanes.Instance.GetActivePlanes(PlaneTypes.Wall); foreach (GameObject plane in walls) { if (Vector3.Distance(plane.transform.position - new Vector3(0, plane.transform.position.y, 0), camera1.position - new Vector3(0, camera1.position.y, 0)) < minDist) { minDist = Vector3.Distance(plane.transform.position - new Vector3(0, plane.transform.position.y, 0), camera1.position - new Vector3(0, camera1.position.y, 0)); Debug.Log(minDist); float cst = Mathf.Abs(character.position.x / character.position.z); character.position = new Vector3(minDist * cst / (Mathf.Sqrt(1 + cst)), character.position.y, minDist / (Mathf.Sqrt(1 + cst))); teleporteur.position = new Vector3(minDist * cst / (Mathf.Sqrt(1 + cst)), teleporteur.position.y, minDist / (Mathf.Sqrt(1 + cst))); } } }
But when I build it I get a nullreference on the walls list.
I use this function when the application launch so do I just have to wait for some time or did I do something wrong ?

Best Answers


  • trzytrzy ✭✭✭

    Argh. I wish these forums had a better markdown format.

  • trzytrzy ✭✭✭

    Anyway, for object placement, consider using SpatialUnderstanding. It's much more complicated but you can perform interesting queries, including finding the largest wall, placing objects on a wall, and constraining them to be a certain distance from the user or other points, etc.

  • Thank you for your answers I'm going to see if I can make this work.

Sign In or Register to comment.