I recently created simple level generator, which creates a level with segments. I used mesh.bounds.x
to see how far from the previous segment that the next segment should be placed. It worked for me pretty well, because all segments were square. Now I decided to make this work with bigger segments with the other sides proportions(still quite rectangular). My problem is that even though I tried many combinations I couldn't set this up properly.
Can somebody explain to me how this mesh.bound
works? I also instantiate rotated segments, maybe this causes some bugs? All my prefabs are imported from blender.
There is part of my code where I instantiate one segment(before I decided to use more complex segments):
size = meshh.bounds.size;
if ((x == 0) && (y == 0))
{
segments[x, y] = Instantiate(prefabs[0], new Vector3(segments[1, 1].transform.position.x - size.x, segments[1, 1].transform.position.y, segments[1, 1].transform.position.z + size.x), segments[1, 1].transform.rotation) as GameObject;
segments[x, y].tag = "Terrain";
}