The child object doesn't follow it's parent. What's the cause of this?
I'm using Unity 2019.02.0f1 Personal Edition. I noticed a strange behaviour of my GameObjects in the viewport of my 2D project. The hierarchy looks like this: -Enemy an empty GameObject, position: 0, 0, 0 scale: 1, 1, 1
-GFX (child of Enemy) GameObject with sprite, position: 0, 0, 0 scale: 10, 10, 1
- Weapons (child of Enemy) empty GameObject position: 0, 0, 0 scale 1, 1, 1
-Left Weapon (child of Weapons) GameObject with sprite position: -10.5, 0, 0 scale 7, 7, 1
-Right Weapon (child of Weapons) GameObject with sprite position: 10.5, 0, 0 scale 7, 7, 1
If it isn't clear look at this screenshot: When the Enemy object is at 0, 0, 0 position the pivot looks normal - it's in the middle as its supposed to But when I move it the rest of the objects doesn't follow and the pivot (crossed arrows) are far away from the rest. I looks like this: The left weapon's pivot moves, but right one's stays in place and the whole enemy pivot is far away.
Does anyone know the cause of this. If you want to recreate this behaviour:
Donload, unzip and import the Unity Package Download this
Place the enemy prefab into the scene (preferrebly at 0, 0, 0)
Move around in any direction.
Thank you in advance.
Answer by Vega4Life · Aug 09, 2019 at 07:02 PM
It's possible your handler is set to 'Center'. Try changing it to Pivot.
Thank you so much. I did solve the problem. Could you explain or provide me link to further reading about this Center/Pivot and Local/Global things? That would be awesome. Again, thank you very very much.
This specific mode has two options: Pivot and Center. Pivot shows the actual pivot point of the selected object. Center shows the center of the rendering bounds - which is often different from the pivot point (but not the case for Unity's primitives).
Not matter which you choose, its an editor only thing. Picking center does not change how something is moved in code. It will always move via the Gameobjects pivot. Some people choose center because it may be easier to align something via its center in the editor as opposed to its pivot.
Your answer
Follow this Question
Related Questions
Scene and Game views freak out during Play mode in 5.3.3 1 Answer
How can I "always" Lock View to an object in the editor window? 0 Answers
Get the center of multiple cubes at runtime (not the pivot) 1 Answer
After Rotating a Prefab, Transform.Position of children is inaccurate 1 Answer
The scrollrect viewport breaks when changing scene 3 Answers