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

Some Objects are able to be picked up others not??

I'm creating a simple app that allows you to decorate your office with christmas stuff. I have a tree, 3d box, and a present. The 3d box and tree are able to be picked up and moved but the present is not able to be picked up and moved.

All 3 have box collides on the object. They are all in a empty object also with the TapToPlaceParent script attached.

What am I missing to get this to work?

`
using UnityEngine;

public class TapToPlaceParent : MonoBehaviour
{
bool placing = false;

// Called by GazeGestureManager when the user performs a Select gesture
void OnSelect()
{
    // On each Select gesture, toggle whether the user is in placing mode.
    placing = !placing;

    // If the user is in placing mode, display the spatial mapping mesh.
    if (placing)
    {
        SpatialMapping.Instance.DrawVisualMeshes = true;
    }
    // If the user is not in placing mode, hide the spatial mapping mesh.
    else
    {
        SpatialMapping.Instance.DrawVisualMeshes = false;
    }
}

// Update is called once per frame
void Update()
{
    // If the user is in placing mode,
    // update the placement to match the user's gaze.

    if (placing)
    {
        // Do a raycast into the world that will only hit the Spatial Mapping mesh.
        var headPosition = Camera.main.transform.position;
        var gazeDirection = Camera.main.transform.forward;

        RaycastHit hitInfo;
        if (Physics.Raycast(headPosition, gazeDirection, out hitInfo,
            30.0f, SpatialMapping.PhysicsRaycastMask))
        {
            // Move this object's parent object to
            // where the raycast hit the Spatial Mapping mesh.
            this.transform.parent.position = hitInfo.point;

            // Rotate this object's parent object to face the user.
            Quaternion toQuat = Camera.main.transform.localRotation;
            toQuat.x = 0;
            toQuat.z = 0;
            this.transform.parent.rotation = toQuat;
        }
    }
}

}

`

Best Answers

Answers

  • Options

    I tried adding
    this.Transform.position = hitInfo.point;
    in the update method of the TapToPlaceParent.cs script
    Like the post says to do.

    It gave me errors that i don't understand how to fix.
    Is that the proper solution?
    I also tried putting my models inside an empty game object like the link said to.

    Thanks for the help.

Sign In or Register to comment.