Positions of objects in the scene - unity3d

My hierarchy of game objects is as follow.
Display(Scene)
Model(-4.708, 1.55, 14.4277)
Pass(4.7080, -1.5, -14.42)
handle(-0.0236,0.65690,0.149)
shaft(5.34,-1.0225,-0.1489)
head(-7.0912,-9.62,-0.5231)​
ball(0,0,0)
We can see Model and its coordinate on the image. Ball has position (0,0,0), but why it is located at the base of the Model?
How can I locate ball just beside the head?

Sounds like the origin point of one or more of the models is at off.
You can adjust this in 3d modelling software, or by making an empty game object inside unity and making your object a child of that object, then using the empty game object as the new origin point, you can adjust the positions of the child objects you assign to it.

Related

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.

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

How can find Center of circle to Unity?

I have circle, and I'm trying to find center and convert to Vector2.
For example:
circleLocation : new Rect( Screen.width/10, Screen.height/2.75, Screen.width/3,Screen.width/3);
centerofcirle:New Vector2(circleLocation.width/3, circleLocation.height/3);
But this example's not correct, the circle is not turn center. What is this formula? How can find correct center of cirle and how to convert Vector2?
Reading between the lines here, I wonder if issue has nothing to do with your code here, but with the rotation point of your steering wheel object, which isn't where you want it to be.
A common technique to change the rotation point of a game object is to make that object the child of another game object in the Unity Editor. Then set the position of the child object as you wish relative to the position of the parent object. Now, rotate the parent object. The child object will automatically rotate around the parent object's position, since it's transform (including position/rotation) is relative to it's parent's.
You seem to be defining your circle using a Rect so just use the Rect.center property:
circleLocation.center;

Is there an easy way to create elastic game objects and get relative coordinates?

Lets say I have the following game object hierarchy:
Board - The entire view of the game's board, made up of tiles.
Tile - A rectangular boundary within a board, made up of subtiles.
Subtile - A rectangular boundary within a tile.
A Board needs relative dimensions with respect to all of the contained Tile objects.
A Tile needs relative coordinates with respect to the containing Board.
A Subtile needs relative coordinates with respect to the containing Tile.
My current process is to define n Tile objects. Space them out x and y, such that x is the number of Subtile objects in a row and y is the number of Subtile objects in a column. Then, when I place Subtile objects, I just multiple the x or y by the containing Tile object's starting coordinate.
This process, so far, works well enough. However, to avoid complication and errors, I'd love to be able to simply lay out a Subtile object, where (0, 0) would be the top-left of the Tile object.
Without just abstracting my positioning a bit and adding classes for, say, SubtileVector or something, which would keep an additional variable for offset relative tile, is there an easier way to do this?
Likewise, when I want to see how big my board is and center my camera in the middle of it, I just end up calculating to that position. Is there any way to have my board always act as the containing box for these tiles, and be able to just do something like Board.Position.Center and get the exact center coordinates?
Yes there is. You can make a board game object, parent it to tile game objects, who on their turn are parent to subtile objects:
Board, parent to
Tile, parent to
Subtile
The good news is you can use the relative coordinates of tile and subtile using using their
transform.localPosition

unity mesh collider not in the same position as the object

I'm currently learning Unity and I want to import a 3D model to my scene (.FBX)
I use mesh collider for detecting collision, but the collider's position is not the same as my 3D object. The mesh's position is above the object and I can't move it....
On imported objects you have two tranforms, one for the game object and the other for the mesh. The mesh's transform is relative to its parent game object and thus should be (0, 0, 0) in most cases:
Mesh colliders are pretty CPU expensive and should be used for simple static objects only. If you have a more complex model, you should consider using a simpler collider.

Categories