I need a tip for a project: basically I need to randomly generate an environment (a map) for a game. As generating a full map completely procedural is impossible for me, I thought to create a static map (I made one ice based, one rock based, one desert based etc) with some static elements in it like a "spawn area", a map border.

Next, I made some "piece of map" smaller that the actual size of the border (like the border is 1000x1000 and this piece are max 200x200). Each piece has the same style of the border (e.g. I made few icy pieces with a spawn of polar bear and few desert pieces with a spawn of scorpions).

Now I'm stuck; I can't randomly spawn all the little squares inside a border & I can't randomly spawn them inside and make them match one with an other. Incidentally, this is a 3D project.

  • 1
    \$\begingroup\$ Why is it that you "can't random spawn all the little square inside a border" ? What specific issue is blocking you from achieving what you want? The better you can describe (or better, show) what your obstacle is, the easier we can help you overcome it. \$\endgroup\$ – DMGregory May 11 '17 at 19:54
  • \$\begingroup\$ A screenshot or mock up of a failed result would also be helpful. \$\endgroup\$ – Pikalek May 11 '17 at 20:54
  • 1
    \$\begingroup\$ This sounds like a straightforward application of the Instantiate(prefab, position, rotation) method with a prefab selected randomly from a weighted distribution. Can you edit your question to explain which of these steps you know how to do, and exactly where you're running into trouble? \$\endgroup\$ – DMGregory May 12 '17 at 9:30
  • 1
    \$\begingroup\$ If you're selecting a prefab at random, then why randomize the position? Just step through your positions in order, and select a random prefab for each one. That way you guarantee no overlaps because you control the spacing precisely. \$\endgroup\$ – DMGregory May 12 '17 at 16:17
  • 1
    \$\begingroup\$ If you need help on stepping through a grid of positions in 3D space, I'd recommend editing your question to describe that problem, what you know how yo do so far, and what part you don't know / isn't working the way you want yet. \$\endgroup\$ – DMGregory May 12 '17 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.