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.

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