Weird X and Y of gameobject in Unity - unity3d

I have one problem. X and Y of gameobject are weird. I think that's because its parent isn't main camera. How to set parent without scripting?

To make a gameObject the child of another, look at your hierarchy and find the gameObject you want to make child, drag and drop it on the other object you want to make parent.
This will make the coordinates relative to the parent.

Related

Use Parent Position but not rotation

is there a way to make a GameObject use parent position but world rotation?
You can separate you rotation and translation into few objects, changing your hierarchy like so:
Moving Cube
- Parent Cube
- Child Cube
now, moving Moving Cube will move both Parent Cube and Child Cube and rotating Parent Cube won't affect Child Cube

Rotate a body about a given point Unity2d

How to rotate a body relative to given dx dy in Unity? For example, I have a weapon sprite with a hand, and I was able to make it rotate relative to its center so that the weapon looks at the cursor, how can I rotate not relative to the center of the sprite, but relative to a given point?
The simplest way to achieve this is to set a gameobject at your desired point and make your object child of the created object. So when you rotate the parent, it will rotate relative to the parent point.
You can create an empty object and set the body as its child, then rotate the parent, the body will rotate around the parent like the parent be its pivot.
This is a practical way to set the pivot, and you can change it at any time.

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.

Unity Gameobject is far away from the Move Tool

why is my Gameobject so far away from the Move Tool as you can see in the Picture down below?
I would like to have it centered at the Gameobject. How can I change this?
GameObject away from Move Tool
Screenshot of Hierarchy
Check the object in the scene hierarchy and make sure that the transform eg. x,y,z are set to 0.
If your object is a child of another object and they are not at the same position you are probably moving the parent and not the child object itself.
that Move Tool is the objects origin, and this might help:
"The easiest way is to create an empty object as a parent object. Then you put the corridor object as a child of the empty object. You can then alter the position of the corridor object so its positioned at the edge.
i found your answer here
note that its not exact, in your case, make an empty object, move it to where you would like your origin or move tool THEN add your other object to it as a child. you can then move it with the parents move tool(origin) right on top of your box.

Unity3D - What does child object inherit from its parent?

What does child object inherit from its parent in Unity except transform (when parent object is moved, then children are being moved too)?
Unity's inheritance isn't like pure OOP inheritance. It's not like a base class provides virtual members that a child inherits.
In Unity a child object inherits only the Transform. It doesn't really inherit it, it just becomes the base for it's own Transform component therefore when modifying the child component it will be relative to the parent. Since all object by default need to at least have only 1 component (Transform) that's pretty much all that can be inherited by a child object.
The child will not inherit the parents transform directly, rather the childs transform becomes relative to that of the parent. So if we take the example of the transforms position, a GameObject without a parent will be relative to the world coordinates, whereas a GameObject with a parent will be relative to the parents position. You can get the relative position using localPosition, which will be equal to the Transform.position if the GameObject has no parents.
As a more concrete example (I'll use 2D coordinates for simplicity):
Say we have a GameObject (A) at world position (0,0) without any parents. Its Transform.position will be (0,0) and Transform.localPosition will also be (0,0).
If we add another GameObject (B), make it a child of A and set its world position to be (1,0) then its Transform.position and Transform.localPosition will both be (1,0).
Now if we were to move GameObject A to (2,0), we would see that B would move to (3,0) in world space, but its Transform.localPosition would still be (1,0) as this is relative to the position of A.
The child won't inherit anything else from the parent, though the relationship can be used in code to obtain references to each other via Transform.parent and Transform.GetChild.