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.

Instantiating Objects with TapToPlace

Hey, So I have a script that I've created to instantiate a prefab on tap. The Tree Manager code (pasted below) is in control of instantiating the tree and placing it in front of the viewer. But I'm having some issues since I've added the TapToPlace script to allow the user to control where the tree is placed immediately after instantiating it.

Tree Manager Code:
`using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.VR.WSA.Input;

public class TreeManager : MonoBehaviour {

public GameObject treePrefab;

GestureRecognizer recognizer;

void Start()
    recognizer = new GestureRecognizer();

    recognizer.TappedEvent += Recognizer_TappedEvent;


private void Recognizer_TappedEvent(InteractionSourceKind source, int tapCount, Ray headRay)
    var direction = headRay.direction;

    var origin = headRay.origin;

    var position = origin + direction * 2.0f;

    Instantiate(treePrefab, position, Quaternion.identity);

This is my Tree Prefab:

Any idea whats going on?



  • What issues are you having?

  • @Jesse_McCulloch When i tap, the trees appear and move around with my gaze, but i have difficulty placing them, and when they eventually get placed, the trees group together in an odd way. I also get the weird effect where my spatial mapping mesh and objects in the room start to jitter a lot, in a very glitchy way and i see the colors start to separate. I then checked my device portal to see if it was any sort of cpu issue and everything seemed to be normal.

    I hope this clears things up. I can take a video to try and replicate the issue as best as possible to show you all.

  • @Jesse_McCulloch So in this video I'm trying to place the trees on the floor and they keep ending up in the air and grouping to one location. When I try and tap on the new trees, i get a small flicker in the background, and can't move the object anymore even though each object has a taptoplace script assigned to it. I think the issue is in my initial tree manager script, but I can't pinpoint exactly what. https://vimeo.com/203733854

  • This is a bit on the old side, but I thought I'd drop this in here.

    var direction = headRay.direction;
    var origin = headRay.origin;

    The headRay parameter isn't actually meaningful in Unity. :\

    I was doing some debugging in my own project and discovered that the values it has are all -107374200.

    Use Camera.main.transform instead (.position for the origin and .forward for direction). https://developer.microsoft.com/en-us/windows/mixed-reality/gaze_in_unity

Sign In or Register to comment.