Search Unity

Generate random level

Discussion in 'Scripting' started by kondor, Oct 21, 2016.

  1. kondor

    kondor

    Joined:
    Jun 18, 2013
    Posts:
    48
    HI,
    I searched online how to this and didn't get the right answer for me,I have an array of gameobjects
    and from this array I would like to generate map.
    I tried to write my own script but it didn't turn well
    someone have an algorithm for this?
    like I thought to instantiate 1 game object and based on his name to manipulate the position
    but it's too much if's and clumsy
     
  2. romatallinn

    romatallinn

    Joined:
    Dec 26, 2015
    Posts:
    161
    It is quite complex and broad task. It depends on what you mean by "level". For example, do you want just put some staff on the terrain (for instance, rocks). Or you want generate a maze from the pre-made parts? It also depends on to what extent it is random. For example, the objects might spawn completely random or just random between the pre-set positions.

    You can also be interested in procedural generation. Google it.
    SOME TUTORIAL
     
    Last edited: Oct 21, 2016
  3. takatok

    takatok

    Joined:
    Aug 18, 2016
    Posts:
    1,496
    Making a map is a pretty broad question. There is a lot that can go into it. However, this tutorial here is probably a good place to start and should help you make your own maps/levels. It uses basic 2D map with sprites:
    https://www.lynda.com/Unity-tutorials/Unity-5-2D-Random-Map-Generation/475939-2.html
    (Note you have to sign up for a free trial to watch it).

    Unity also has some tutorials on their site about dungeon generation. This tutorial has some good core ideas about it:
    https://unity3d.com/learn/tutorials/projects/2d-roguelike-tutorial
     
  4. kondor

    kondor

    Joined:
    Jun 18, 2013
    Posts:
    48
    I want to generate a map from pre made pieces
    the tutorial looks good I will check it out
     
  5. AlucardJay

    AlucardJay

    Joined:
    May 28, 2012
    Posts:
    328
  6. MattMirrorfish

    MattMirrorfish

    Joined:
    Dec 8, 2013
    Posts:
    40
    If you're looking for a paid asset, this is one I made: http://www.mirrorfishmedia.com/strata/

    Strata is an easy to use procedural toolkit for generating 2D levels which use a combination of hand-authored and procedurally generated content. It works at edit time or at runtime without additional programming. Strata works with Unity’s native 2D Tilemap tools allowing you to hand-author pieces of levels and arrange and combine those pieces in interesting ways.

    The design philosophy of Strata is strongly inspired by both classic roguelike dungeon crawler design approaches along with the newer school of action roguelike / roguelite games. To this end, the project contains demos both for a classic top-down roguelike dungeon generator, and a 2D platformer built from a connected chain of handmade rooms. Both serve as good starting points for your own creations.

    Programming procedural level generation tools can be complex and difficult, and with Strata, I hope to open the creation of procedural content to artists, level and game designers and other non-programmer creators.