- Home /
How can I instantiate new prefabs on top of older ones.
If I instantiate a prefab, and then instantiate the same prefab again, the second prefab will be on top of the first prefab on the Z-axis even though they are identical. Each new prefab I instantiate will move to the top of all the previous prefabs. Is there a way to make my newly instantiated prefab do the opposite? (Go behind all existing identical prefabs).
Comment
Best Answer
Answer by eldruz · Feb 28, 2017 at 07:47 AM
You can specify the position of the newly instantiated object directly in the Instantiate function (as shown in the documentation page here) doing something like this :
Instantiate(prefab, new Vector3(i * 2.0f, 0, 0), Quaternion.identity);
Or alternatively you could always alter the transform.position of the object you just instantiated.
Your answer
![](https://koobas.hobune.stream/wayback/20220612111906im_/https://answers.unity.com/themes/thub/images/avi.jpg)