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.
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
-
OptionsHoloSheep mod
If some of your objects are responding and some are not you may want to check that the pivot point of each object is inside the box collider.
Here is a post (and a few sub linked posts) that talk about adjusting the pivot or origin point of an object in Unity.
Bottom line is that if the origin of the object is outside the box collider the taptoplace event might not get fired as described in this post.
Windows Holographic User Group Redmond
WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
WinHUGR YouTube Channel -- live streamed meetings5 -
OptionsHoloSheep mod
If you are referring to this post it does not suggest that you should add a line in the update method of the TapToPlaceParent.cs, it is simply explaining the behavior of the TapToPlace.cs (note the difference, no Parent) that comes from the HoloToolkit.
Sorry, I missed the fact that your original post mentions that you are using the TapToPlaceParent.cs script.
However, note that a very similar line also exists already in the TapToPlaceParent.cs script, the main difference is that it is moving the parent container and not the object itself... which can make things a little messy with the redirection.
It would simplify things if you were to use the TapToPlace script from the HoloToolKit in a similar fashion as to the general steps described here, but that would be a slightly different parent/child relationship with respect to where you attach the scripts.
My original point was to make sure that you have the pivot point of the object that you are moving inside the box collider.
The explanations that I point you to are all based on each object having it own empty gameobject wrapper (which I called ModelBase and you would need to make unique incremented versions for multiple objects).
each ModelBase would also have- TapToPlace.cs attached to it
- a child gameObject with a relative position to the ModelBase for origin correction
- a box collider
If you use a different hierarchy your mileage may vary, but the same concept of ensuring that your origin point is inside of the associated box collider is the key. Unfortunately, if you do not create all of your own models in a 3rd party modeling tool that allow you to set the models origin point, the only easy way to adjust that origin point is to use empty gameobject wrappers.
TapToPlaceParent.cs from the Origami project I believe was more about containment of the various child objects on a stage and might not translate well if you want your children to be independent and not grouped on a stage.
HTH.
Windows Holographic User Group Redmond
WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
WinHUGR YouTube Channel -- live streamed meetings5
Answers
@JD_Holo_Dev
If some of your objects are responding and some are not you may want to check that the pivot point of each object is inside the box collider.
Here is a post (and a few sub linked posts) that talk about adjusting the pivot or origin point of an object in Unity.
Bottom line is that if the origin of the object is outside the box collider the taptoplace event might not get fired as described in this post.
Windows Holographic User Group Redmond
WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
WinHUGR YouTube Channel -- live streamed meetings
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.
@JD_Holo_Dev
If you are referring to this post it does not suggest that you should add a line in the update method of the TapToPlaceParent.cs, it is simply explaining the behavior of the TapToPlace.cs (note the difference, no Parent) that comes from the HoloToolkit.
Sorry, I missed the fact that your original post mentions that you are using the TapToPlaceParent.cs script.
However, note that a very similar line also exists already in the TapToPlaceParent.cs script, the main difference is that it is moving the parent container and not the object itself... which can make things a little messy with the redirection.
It would simplify things if you were to use the TapToPlace script from the HoloToolKit in a similar fashion as to the general steps described here, but that would be a slightly different parent/child relationship with respect to where you attach the scripts.
My original point was to make sure that you have the pivot point of the object that you are moving inside the box collider.
The explanations that I point you to are all based on each object having it own empty gameobject wrapper (which I called ModelBase and you would need to make unique incremented versions for multiple objects).
each ModelBase would also have
If you use a different hierarchy your mileage may vary, but the same concept of ensuring that your origin point is inside of the associated box collider is the key. Unfortunately, if you do not create all of your own models in a 3rd party modeling tool that allow you to set the models origin point, the only easy way to adjust that origin point is to use empty gameobject wrappers.
TapToPlaceParent.cs from the Origami project I believe was more about containment of the various child objects on a stage and might not translate well if you want your children to be independent and not grouped on a stage.
HTH.
Windows Holographic User Group Redmond
WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
WinHUGR YouTube Channel -- live streamed meetings