Unity all objects have same position - unity3d

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.

Related

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.

Importing an exported .FBX from Blender to Unity object transform issue

Alrighty,
I have a dumpster model I have exported from Blender as an FBX. The transform, rotation and scales have all been applied in Blender. when importing into Unity and then adding to the scene, the model is elevated and rotated at an odd angle to the transform as per the image.
The model has an armature for animating the lids an I have applied the location, rotation and scale on it as well.
Any one else come across this or know of a fix?Thanks
Blender image
Incorrect dumpster transform and location image
The problem is that Blender uses the right-handed coordinate system which means the Z-axis is pointing upwards.
Unity uses the left-handed coordinate system which means the Y-axis is pointing upwards.
To fix this, set the X-axis rotation of the model to be -90. Press Ctrl+A and apply rotation. The X-axis rotation will look like it is now 0 after that. Set it to 90 again and export it to Unity.
This 3 minutes video should also help you do this if you are still confused.
If you still have problems, check your animation. Don't apply it to your model and see if it's the problem.
Also as a side note, you can use blender files (.blend) directly with unity. So every time you modify them inside your project folder they change in unity as well.
The simplest way to solve this would be as follows:
Create a dummy game object (D)
Transform/offset the position of D to make sure your object's position align with the dummy parent
Put your game object as the child of the dummy game object D
You can then apply transform on D, rather than your own game object directly.

How can two GameObjects at different positions in the world space have the same position values under the transform attribute?

I have two gameobjects at different positions in the world space. But the position values under the transform attribute shows the same value.One object is a cube and the other one is a chess piece (a prefab).Here is the screenshot of the window with the objects. I'm completely new to unity and it would so helpful if someone could help me sort this out.Thanks.The screenshot the whole window.
If none of them isn't child of other gameObjects ,then maybe pivot of chess gameObject is not in center of your mesh ,check your 3D model of chess and set its pivot to center of gameObject.
Your chess piece is certainly set as child of an object located around (X=3.5, Y=2.0, Z=4.5) coordinates. Unity displays the localPosition of Transform components.
In your print screen you have scaled one of the objects 10 times. Could it be that the anchor of that object is at 0, 0, 0 but the rendered Chess piece is then rendered with offset.
Expand your mesh renderer and see if there are any offset variables

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.

Importing objects form blender to unity correctly

I have recently done few 3d objects in blender and I want to import them int unity3d. I know the basics: that I should export it to FBX file. But I wonder if there are any other things that are very important while exporting to unity? For example where should i position center of my object(near the ground or in the center)?
Typically you want the origin to be the bottom of the character (feet), and another good idea when importing is to make the model a child of an empty object before saving it as a prefab. That parent empty object will then have driver scripts that control stuff like movement and animation.
EDIT: This is one example of why you might want to do the empty parent method, but it isn't directly applicable to your question: http://docs.unity3d.com/Manual/HOWTO-FixZAxisIsUp.html
1) apply location, rotation and scale.
2) set the origin of the model to the bottom.
3) Delete camera and lights