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.

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

  • Accepted 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

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

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

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

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

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

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