Hello everyone.
Have you ever tried to parent a gameObject un under a scaled father ?
The scaling in herited, and your GameObject is scaled with weird scaling parameters.
But how setup a child under a scaled parent without impacting the scale ?
Try this context:
It works !
Now The scale is preserved, but the gameboject is rotated as the parent, so now I need to reset the rotation to
(By rotating in UI, I found these empiric values : (350,25,300) )
Anyone have some clues to findout how to restore/preset basic transform values while parenting ?
Create an empty GameObject. It has a scale of 1x1x1. Assign the scaled object as the parent. Then assign the empty GameObject as the parent to your desired child object. Now the Hierarchy should look like this:
MyCubeAsParent
EmptyGameObject
MySphereAsChild
I tried this, and somehow it worked. Apparently it only scales the object according to the immediate parent’s local scale. The code looked something like this:
var emptyObject = new GameObject();
emptyObject.transform.parent = myCubeAsParent.transform;
mySphereAsChild.transform.parent = emptyObject.transform;
It’s not clear what elements of the parent’s transform you want inherited by the child, and what elements you don’t, so I can’t give you a very exact answer. I will tell you, though, that parenting an object to a parent with a non-uniform scale will generally give you results that you weren’t expecting. If you want to scale the parent mesh, it’s a better idea to make the two meshes siblings, and put the scale in the mesh node instead of the (new) parent node.