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.

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

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.