This project shows a number of different patterns to use with Tilemaps to create custom maps. All the main functions are within the script MapFunctions.cs.
Within this project there are scenes showing examples of the following algorithms:
- Perlin Noise
- Basic Generation (for top layer)
- Smoothed Generation (for top layer)
- Cave Generation
- Random Walk
- Basic Generation (for top layer)
- Smoothed Generation (for top layer)
- Cave Generation (4 directional movement)
- Custom Cave Generation (8 directional movement)
- Cellular Automata
- von Neumann Neighbourhood
- Moore Neighbourhood
- Directional Dungeon
There is also an example of using multiple types of generation for one tilemap. This can be seen in the Multi-Generation Example subfolder.
Within each scene there will be an object named LevelGenerator. This object holds the LevelGenerator.cs Script, the exception to this rule is the multi-generation example scene. The object named LevelGenerator in this scene holds a customised version of the LevelGenerator.cs script which allows for multiple types of Map Settings
On this game object, you can generate and clear the level in edit mode using the buttons provided
To create a new map setting object, you need to right click in the project view then go Create->Map Settings.
or
You can got to Assets->Create->Map Settings from the toolbar
The good thing about the MapFunctions.cs script is that you can take it out of this project and put it into any other project. If you want to call functions from the script you would just need to do the following:
int[,] map;
map = MapFunctions.GenerateArray(width, height, empty);
map = MapFunctions.PerlinNoise(map, seed);
MapFunctions.RenderMap(map, tilemap, tile);
What this code would do is:
- Create an int array for a map
- Generate the array into the map
- Generate perlin noise within the map
- Render the map to a tilemap
Software Requirements
Required: Unity 2017.3, or later version
Hardware Requirements
Required: Any Computer (Windows or Mac)
Owner and Responsible Devs
Owners: Ethan Bruins ([email protected])