Skip to main content

Posts

Showing posts from May, 2015

Random Map Generator

A lot of games use Perlin Noise to generate maps, so I decided I would give it a try. One of the most popular games to do this is Minecraft which uses a similar noise function to create its map.  Landscape generated in MineCraft The basic premise is that you use the noise to create a height map on a 2d grid. Every point on a grid is assigned a random value and that value is its height. If you where to just use a normal random number function to assign the values they would be all over the place. It wouldn't make any natural looking shapes. That is why Perlin Noise is used. It creates smooth gradients between random points. This make the height changes less jarring and look natural. Perlin noise vs white noise  Unity already has a Perlin noise function so I did not have to implement my own. All I did at first was make a 2d array and assign each index a height value. Every height above a cutoff is land and everything below is water, this is the result. It was a lo