How to properly position gameObjects one after the other (C#)
Hello, I'm working on an endless runner game (something like temple run) for a college essay. I'm stuck on finding a way to position the "piece" of the stage (which I already randomly instantiate and cache), one after the other, on their correct attach sites.
Here is an example of how my pieces looks like.
They can be straight or curve, with one begin and one or more ends, with possible slopes and/or dead ends.
I need a tip to find the blue spot locations (of course there are not "blue spot thingie" in the prefabs. So a computation based on the mesh is required I think) and save in an array of Vector3, in order to be able to properly attach them.
In the script attached on each prefab I already defined how many ends and where they are (on the left, forward, ecc) for that peculiar prefab.
Thank you very much.
Answer by TheCallipo · Jan 18, 2017 at 10:20 AM
I would just put a empty game object on the prefabs as a child and set its location to these spots in the editor.
Then Instantiate the next pieces at the spotGameObjects transform
Your answer
![](https://koobas.hobune.stream/wayback/20220612104613im_/https://answers.unity.com/themes/thub/images/avi.jpg)