Parenting an object changes transform of its parent - unity3d

I was trying to set up steering wheel pivot for my spaceship so it rotates correctly. In order to do this I created empty object in the position where I want the pivot(img 1) to be and then parented the steering wheel(img 2) to this pivot. I thought all pivots would stay in the same place in global space and only changes would happen to the steering wheel in local space. I'm confused because it actually changed the position of the pivot as well(img 3), although the only thing I did was parenting the steering wheel to it. Pivot was moved to where steering wheel transform previously was.
img 1
img 2
img 3

Have you tried changing the tool handle location from Center to Pivot?
(The switch is located in the top left of the screen near the tool selector)
Also note you can change the location of the tool from Global to Local.
Hope this helps,

Related

Standing inside an Object without clipping

My Application is a simulation of a 3D-Audio cage we have in our lab at uni.
To best simulate it, we made it a wireframe-sphere.
I need to be able to stand inside the cage, but if my Sphere is around my Camera, it clips, so it doesn't render until i move away.
I also need to be able to Rotate it, but not move it.
Is there a way to disable clipping for this case? What else can i try to get the desired result?
I've tried to set the clipping pane for the camera to 0, but 0.01 is the lowest it can be.
Also I've tried to use a transparent shader, both tries left me the same problem of the object clipping.
Object visibility when inside
Is there a way to disable clipping for this case? What else can i try
to get the desired result?
You can invert the normals of the sphere. Or model a sphere with normals on the inside and the outside if you want to look at it from both sides.
Another solution could be to use a shader with disabled backface culling (Cull off).
This stackoverflow answer might be helpful: Flip Normals in Unity 3D/spheres
Missing Manipulation Handler (MRTK)
If I understand the ManipulationHandler correct, you can make a smaller sphere with a ManipulationHandler inside the larger sphere and copy the transform changes to the larger sphere.
If you want to keep the larger sphere at the same place don't copy the position changes.

Unity all objects have same position

I have a 3d building model in my Unity project. It has many children like doors, walls etc. The problem is, all of the children points to same position in the Unity world (24.97, -2.08, 19.35). Their transforms show this position. And this position is far away from their actual one. How can i fix this?
I tried freeing all children from parent but this didn't change anything.
I want them to show their real position, which appears with move tool when we click upon them.
Here is the image link
It seems that this is simply their pivot point exported "wrongly" from the 3D editor your model was made with.
This won't change until you export it correctly from a 3D editor (Blender, Maya, etc).
Unity is not made for 3D mesh modeling and therefore in Unity itself you can't change the pivot points.
There is a very simple fix
Add a new empty GameObject
In the Inspector go to the Transform component, click on the context menu and hit Reset (you also simply set it to position 0,0,0 rotation 0,0,0 and scale 1,1,1) assuming the pivot should be at 0,0,0
Now drag and drop all objects into the empty GameObject
=> You have now one parent object with correct pivot.
By wrapping it in a parent object the childrens pivots don't matter anymore. You can simply do all translation, rotation and scaling on the parent object with the correct pivot and don't have to care about that "wrong" position at all.

finding submesh in Unity 2017

How can I find submesh under my mouse NOT using Raycasting? Is any way to do it? I know how to do it clicking on object and using raycast but completely haven't idea how to id it without it. I need it because of bug in Unity - I can't update version of Unity, so I need to find any solution.
You can see if your mesh contains the mouse.
You get the position and the size of the mesh which allows you to create a square or a cube (whichever you need) and then you just see if your mouse fits within that square or a cube. If so, then you want to select that mesh.
https://tutorialedge.net/gamedev/aabb-collision-detection-tutorial/
or
If your object was a circle/sphere then you can perform a simple distance check between mesh's origin and mouse, if the distance is <= than the radius of the object, then you want to select that mesh.
http://cgp.wikidot.com/circle-to-circle-collision-detection
It is similar, just instead of using 2nd object, you are using a mouse.

How to change pivot of a node

I tried this
xxxx.pivot = SCNMatrix4MakeTranslation(0.5, 0.5, 0.5)
But it does not make it centered. What is the best way of doing that with code?
Center the pivot to the center of the object, and the object to the center of the world, in Blender, Cheeatah 3D, 3D studio Max or any other suitable software and then re-export it with the pivot in the proper position. Changing the pivot in code does not have the same effect and will quite likely lead to other issues once you want to translate, rotate, scale etc. Offsetting the pivot through code is not really meant as a fix for an incorrectly placed pivot which is actually the result of the vertices having the wrong positions. Rather than trying to patch that in code, fix it properly in a 3D modeling package.
A little confused about the question. Are you trying to center the couch on the coordinate origin? Why are you using pivot instead of translation? The pivot property moves the local coordinate system origin relative to the object itself (i.e. setting the upper left corner of the couch to be 0,0, instead of the center). Whereas translation moves the object in the scene but maintains the object's position relative to its own coordinate system. Which are you trying to accomplish?
https://developer.apple.com/documentation/scenekit/scnnode/1408044-pivot

unity5, box collider 2d size doesn't match platform

I created a 1x7 platform. then added a box collider 2D and set the size to 7. you can see in the picture. the platform and box collider are not matching. how can i get it fixed?
X Offset is the easy answer and definitely not a bad one, but maybe not the best one since it could make this problem show up in other areas.
BoxCollider2D by default has its origin at the center of the object ( where the translate tools are showing).
Since the translate tool is at the middle of the platform, the collider should be centered on it as well.
There are several possibilities that I can think of:
The sprites do not have their pivot at the center (If you want it
that way, use Offset to center the box)
The children of the selected object are offset (They should be
shifted over to line up with everything else, unless you need them
this way for some reason)
Create an empty Gameobject - add any sprite objects that you need in there - press the "GameObject" button in the menu and select "Centered on Children" in order for the empty object to be centered properly. This will have to be done each time you add a new object into the bulk. Hope this helps.