Hello,
I’m trying to instantiate a prefab and set it as a child of another game object, so that the prefab’s transform will be relative to the parent’s.
However doing the following:
map = (GameObject)Instantiate (Resources.Load ("somefile"));
map.transform.SetParent(gameBox.transform);
The prefab object’s own transform values get set to the inverse of the parent’s transform, losing it’s original values.
So if the prefab pos was (0, 0, 90), and the parents pos is (1, 1, 90), after setting the parent transform, the prefab pos becomes (-1, -1, 0).
I can reset the values myself by hard coding them in after setting the transform, but being as its a prefab, it kind of loses the point of storing all those magic numbers for me.
What am I missing?
Thanks,
-Ryan