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

Place Hologram on Spatial Mesh

Hi,

So like many other this question is posted because of lack of proper tutorials for HololenseToolkit. I'm just getting started with the toolkit and all I want to do right now is move a hologram on the spatial mesh. I've the hologram working and I can drag it around but it doesn't collide with the spatial mesh, even though I've set a Box Collider and a Rigidbody (w/ Kinematics) on the cube. It just goes though the mesh when I drag it.

I've checked out the MR Spatial 230 tutorial but it is outdated and does not work anymore. So does anyone have any information on how to do such a basic task? All I need is collision between my cube and mesh using the Physics engine in unity.

I'm using HandDraggable script from the toolkit to allow movement of the hologram.

Thanks

Best Answer

  • Options
    Answer ✓

    The issue I was having was that HandDraggable does no physics checks while dragging so I did a edited to file to raycast to the new position before moving and if it collided with something it wouldn't.

Answers

  • Options

    You could check TapToPlcae.scene, which shows the way of moving and dragging gameobjects. And please notice that the Kinematic checkbox of your cube should be turn off.

  • Options

    @Akira_Chen I checked out the scene. It does not work. At least on the emulator in Unity. I did download the latest version less than a week ago.

    And I do need to the Rigidbody to be Kinematic other wise it "fights" the physics engine and jitters when you move it. At least from my experience.

  • Options

    @Akira_Chen The only thing I need to know is why my objects aren't colliding with the spatial mesh when they all have mesh colliders. And so does my cube. The physics setting in unity shows that they should be colliding.

  • Options
    Answer ✓

    The issue I was having was that HandDraggable does no physics checks while dragging so I did a edited to file to raycast to the new position before moving and if it collided with something it wouldn't.

  • Options

    Can you share the code I'm trying to do the same thing

  • Options

    @laurens I only wanted collision with floor so here the snippet, it's taken out/added in of the UpdateDragging function in the HandDraggable.

     // Apply Final Position
    if (hostRigidbody == null)
    {
    //  HostTransform.position = newPosition; // code in the toolkit.
        if (!Physics.Raycast(HostTransform.position, newPosition - HostTransform.position, Vector3.Distance(HostTransform.position, newPosition)))
        {
            HostTransform.position = newPosition;
        }
        else
        {
            if (HostTransform.position.y < newPosition.y)
            {
                HostTransform.position = newPosition;    
            }
        }
    }
    

    You need to have no rigidbody attached for the code to flow through this, otherwise it moves the rigidbody. You get the general idea that you want to raycast in all direction you want to check for collisions and move only if there are not collisions. Lemme know if you are confused.

Sign In or Register to comment.