0

When instantiating an object from prefab by this way (in an empty project, Unity 2020.3.2f1):

myObject = Instantiate(preObject, Parent.transform);

This one changes myObject's shape very much. Actually, I don't know why.

Found a decision:

myObject = Instantiate(preObject);

myObject.transform.parent =Parent.transform

Is this a bug or Im just that lazy, I can't read documentation?

Beso
  • 1,176
  • 5
  • 12
  • 26
A1exander
  • 1
  • 1
  • Just a guess. But has the parent object any other localScale than 1,1,1?? (Any of the parents for this matter) If the parent is streched eg 1,1,2 it will also affect its children. – GoldenDremora Oct 17 '21 at 12:35
  • It was stretched 10, 10, 1. I'm not sure, if it was lossyScale or localScale. Going to do the same thing for cube 1,1,1 today – A1exander Oct 20 '21 at 12:24
  • Golden Dremora, you are actually right. Parent was stretched by localScale, and that effected on children. lossyScale is read only, so the only way I know right now - is what written above – A1exander Oct 21 '21 at 19:44

1 Answers1

0

I cant make a comment because I dont have enough rep ..

You could also set the transform as a parent and than just set the child scale to 1/parentScale.

obj = Instantiate(newObj, parent);
obj.localScale = new Vector3(1/parent.localScale.x, 1/parent.localScale.y, 1/parent.localScale.z);

If you have more than one parent with streched scale you can try the same with parent.losssyScale