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.
TapToPlace - Cube works, my model does not
Thanks for your help on my previous question about the HoloToolKit. I was having problems getting started with TapToPlace. I've successfully added the prefab, and the scripts. I can tap to place and move a simple cube. In my app I have a 3d model that I imported from SolidWorks. It has a box collider. I dropped taptoplace on that as well. When I run my app, I can tap/place the cube and it looks like I can tap on my model and begin moving it but I am unable to place it. Visually, the only thing that seems different is when I move the cube, the BasicCursor is centered on the cube, while on my object the cursor seems to be offset (not sure why)
Best Answer
-
OptionsHoloSheep mod
@Simusid this is likely due to the origin point on the model you imported.
The creator of the model made a decision as to where to put the origin. That origin is also used by the TapToPlace script once the move action starts.
In the update routine there is a line:
this.Transform.position = hitInfo.point;
That line is basically setting the origin point of your model to your gaze point.
So then when you tap to place it somewhere if that origin point on your model is not inside your collider, the tap does not get detected.
The origin of a cube is dead center of the cube by default, so its origin is typically inside any collider you put around it.
If you look at your model in the Unity Editor and select it in the hierarchy in the "Translate" mode, you will see the origin point of your model as well as the box collider.
You can either make your collider big enough to include the origin, or you can use the wrapping technique where you place your model inside an empty game object as a child and adjust the child's transform to position the point in your model that you want to be the origin at the same spot as the origin of the wrapping empty game object. Then treat the wrapper as the object and attach the scripts and colliders to the wrapper.
Alternatively if you are the creator of the model or have the tools and knowledge to do so you can also edit the original model in a model editing tool like 3DS Max, Maya, SketchUp etc.. to reposition the origin in the source file and reimport the modified model into Unity. However that tends to be less convenient when after the fact.
Here are a couple other posts where I talk about origin points.
Manipulation using colliders thread
HTH
Windows Holographic User Group Redmond
WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
WinHUGR YouTube Channel -- live streamed meetings6
Answers
@Simusid this is likely due to the origin point on the model you imported.
The creator of the model made a decision as to where to put the origin. That origin is also used by the TapToPlace script once the move action starts.
In the update routine there is a line:
this.Transform.position = hitInfo.point;
That line is basically setting the origin point of your model to your gaze point.
So then when you tap to place it somewhere if that origin point on your model is not inside your collider, the tap does not get detected.
The origin of a cube is dead center of the cube by default, so its origin is typically inside any collider you put around it.
If you look at your model in the Unity Editor and select it in the hierarchy in the "Translate" mode, you will see the origin point of your model as well as the box collider.
You can either make your collider big enough to include the origin, or you can use the wrapping technique where you place your model inside an empty game object as a child and adjust the child's transform to position the point in your model that you want to be the origin at the same spot as the origin of the wrapping empty game object. Then treat the wrapper as the object and attach the scripts and colliders to the wrapper.
Alternatively if you are the creator of the model or have the tools and knowledge to do so you can also edit the original model in a model editing tool like 3DS Max, Maya, SketchUp etc.. to reposition the origin in the source file and reimport the modified model into Unity. However that tends to be less convenient when after the fact.
Here are a couple other posts where I talk about origin points.
Art First thread
Manipulation using colliders thread
HTH
Windows Holographic User Group Redmond
WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
WinHUGR YouTube Channel -- live streamed meetings
Brilliant explanation. Thank you.
TapToPlace, What process did you use to export out of Solidwork and into Unity? What stage did you texture your 3D and where?
Anyone got an Idea how I can modify the TapToPlace Script in order to place Objects using their Collider ? ie. bounds.center or something like that?