- Home /
Random Block Positioning - Relevant
Hello,
I'm working on a little side project - what I'm trying to do, is build a random track builder (so every time I hit start, a new, different track is built). So, essentially, something like this:
I just want to hear from you guys in how I would go about doing this, in terms of systems I could incorporate. Right now, I have 3 prefabs, one thats a straight platform (spheres located top and bottom), a left one (spheres bottom and left), and a right one (spheres located bottom and right).
The spheres are just to give me an idea if they are connected okay (in the future, I might add a road you see - I want to know if they will connect up correctly).
Any advice/tips would be much appreciated
Answer by Piflik · Jan 14, 2013 at 04:32 PM
If you only use 90° turns, this is not too hard. You just with a start tile, and then add one of three possible tiles: right turn, left turn or straight ahead, all in relation to the last direction you went. The hard part is to close the loop. You would have to somehow keep track on where you are currently, in relation to the starting position, and calculate a valid path to that point, staying on the grid and avoiding existing tiles. A twodimensional boolean array should be useful.
The actual implementation needs some additional brainpower ;)
Your answer
![](https://koobas.hobune.stream/wayback/20220613090930im_/https://answers.unity.com/themes/thub/images/avi.jpg)