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.

Raycast to holograms when picking up other holograms

Currently I'm using the HoloToolkit scripts to pick up and place objects around however when I try to move and place the object onto another hologram, it doesn't recognize the hologram's mesh collider, only the spatial mesh's collider (it only allows me to move and place objects around onto the spatial mesh). I'm thinking the issue has something to do with the Physics Layer in the Spatial Mapping Manager script and layers but I'm not sure what exactly. I've tried setting Physics Layer to 0, the default where all my holograms are placed and this problem is solved, although the raycast is messed up and moves the hologram back and forth towards the camera when I try to pick it up and move the holograms.

Any help would be appreciated,
Thanks

Best Answer

  • timgtimg mod
    Accepted Answer

    You should move the object you are trying to place out of layer 31, or change the TapToPlace script to ignore the object you are trying to place.
    The Raycast is hitting your object and trying to placing your object on itself. Since the collider for your object is closer than the pivot (center) of your object, this has the side effect of zooming your object towards the camera.

Answers

  • The default Raycast code in the HoloToolkit uses the SpatialMappingManager.PhysicsRaycastMask to determine what to intersect with. The default is to only intersect with the layer that contains the spatial mapping mesh (layer 31). If you want the Raycast to treat your hologram(s) as a part of the mesh, you have two options: put your holograms in layer 31 (SpatialMappingManager.PhysicsLayer) or adjust the code in the HoloToolkit TapToPlace script (if that's what you're using) to include the layer(s) where your holograms are in its Raycast.

  • @timg I've tried setting all my gameobjects in layer 31 (and not the input managers, camera cursor, etc) and I've also tried editing the Update function in TapToPlace to include all layers by removing the ignore layer parameter for the raycast. Either seems to work and the raycast now recognizes gameobjects however the issue now is that, say if I pick up a cube, the cube will slowly zoom towards the camera and then reset back to the camera gaze position in a jerky motion (this occurs with all objects I try to move around). I believe this is still an issue with the raycast and it might not be registering the camera gaze position properly.

  • timgtimg mod
    Accepted Answer

    You should move the object you are trying to place out of layer 31, or change the TapToPlace script to ignore the object you are trying to place.
    The Raycast is hitting your object and trying to placing your object on itself. Since the collider for your object is closer than the pivot (center) of your object, this has the side effect of zooming your object towards the camera.

  • Yep that seemed to work. All I did was change the layer to 0 when the gameobject is currently being placed in the TapToPlace and back to 31 if not being placed.

    Thanks again for your help :smile:

Sign In or Register to comment.