Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Creating a random grid-based map

Discussion in 'Scripting' started by anthizumak, Jan 8, 2014.

  1. anthizumak

    anthizumak

    Joined:
    Jan 8, 2014
    Posts:
    1
    Hi everyone! I am a motion designer and I am very new to scripting (I have some web experience only) and Unity (this is my first post)

    I am trying to create a very simple 2d map that consists of a random selection of deserts, mountains, grass and forests (for which I have 1000x1000 px images to represent)

    So, essentially at the start of each game I want to automatically create a 10 x 10 grid of these images. It may be more complicated than I am anticipating.

    I'd like to do this with UnityScript

    I would also like to design it in a way that I can eventually give these terrain tiles a value, and that the map wont exceed a certain value when generating itself. For example, if a mountain equals 3, and everything else was 0, and I don't want my map to have too many mountains, I would put a limit of like 12 so there would only be 4 mountains generated. I'd also like the tiles to store data for things that affect stats etc in the game. That might be too ambitious for now though.

    Any help to get me on the right track is greatly appreciated!

    Thanks!:D
     
  2. exiguous

    exiguous

    Joined:
    Nov 21, 2010
    Posts:
    1,749
    i suggest having all terrain images in the same texture (power of 2 sidelengths!) and then just create a mesh with 4 vertices for each tile and set its uv coordinates to represent the desired terrain. there is a free project named procedural examples in the asset store to get you started with mesh creation.