Skip to content

mpewsey/ManiaMap.Unity

Repository files navigation

ManiaMap.Unity

Docs Unity ≥ 2022.1 Version

About

This package provides components for interfacing the ManiaMap procedural layout generator with Unity.

BigMap

Installation

To add the package to a project, in Unity, select Window > Package Manager.

Unity Package Manager

Select Add package from git URL... and paste the following URL:

https://github.com/mpewsey/ManiaMap.Unity.git

RECOMMENDED: To lock into a specific version, append #{VERSION_TAG} to the end of the URL. For example:

https://github.com/mpewsey/ManiaMap.Unity.git#v1.0.0

Example

The following subsections outline how to procedurally generate a layout.

Step 1: Create Room Templates

The generator creates rooms by pulling from user-defined rooms. To the generator a room is essentially a collection of cells in a grid, with information, such as door connections, assigned to them.

Creating a Room

  1. Create a new Room by selecting GameObject > Mania Map > Room. Create a prefab for this Game Object that may be utilized later.
  2. In the inspector, provide a name for the room, along with its width and height in terms of cells.
  3. Click the Update Room button to generate the cells.

Generated Cells

  1. In the scene view, select any empty cells and set the Is Empty flag in the inspector. The cell Gizmos will show crossed out for empty cells.

Empty Cells

  1. Next, add all possible doors and collectable spots to the room per the following sections.

Creating Doors

  1. Create a new Door by selecting the Room Game Object then GameObject > Mania Map > Door. The door should be added as a child of the room.
  2. At this point, you should probably create a prefab for the door with art supporting the particular direction, along with all applicable events. However, those specifics are beyond the scope of this example.
  3. Position the door at the desired location within the room and assign its direction and connection constraints.
  4. To auto assign the closest cell and direction to the door, make sure the applicable flags are selected and click the Auto Assign button. Note that the Update Room button on the Room component will also perform this operation on all doors in the room.

Doors

Creating Collectable Spots

  1. Create a new CollectableSpot by selecting the Room Game Object then GameObject > Mania Map > Collectable Spot. The collectable spot should be added as a child of the room.
  2. At this point, you should probably create a prefab for the collectable spot with art (treasure chest, orb, sparkle, etc.) and all applicable events. However, those specifics are beyond the scope of this example.
  3. Position the collectable spot at the desired location within the room and assign a collectable group to it (Assets > Mania Map > CollectableGroup).
  4. To auto assign the closest cell to the collectable spot, make sure the applicable flag is selected and click the Auto Assign button. Note that the Update Room button on the Room component will also perform this operation on all collectable spots in the room.

Collectable Spot

Saving Room Templates

  1. Ensure that any rooms are saved as prefabs within the project. Next, select Mania Map > Batch Save Templates from the menu to save room templates for all room prefabs discovered within the project. Note that the settings for this action may be configured in the settings at Resources/ManiaMap/TemplateSaveSettings once the action has been run once.

Step 2: Create Room Template Groups

  1. Create a TemplateGroup by selecting Assets > Mania Map > Template Group.
  2. In the inspector, provide a unique name to the group and add any of the generated room templates you wish to associate with the group to the list.

Template Group

Step 3: Create Layout Graphs

  1. Create a LayoutGraph by selecting Assets > Mania Map > Layout Graph.
  2. Double click on the asset to open the graph editor.
  3. Add rooms (nodes) to the graph by right-clicking in the graph area and selecting Add Node.
  4. In the inspector, add a template group to the selected nodes to associate the room templates that may be used at those locations.
  5. Add edges to the graph by right-clicking a node, selecting Add Edge, then selecting another node.
  6. To edit the edge attributes, ensure that View > Toggle Edge Display is enabled, then select the edges in the graph area.

Layout Graph

Step 4: Create Generation Pipeline

  1. Create a GenerationPipeline by selecting GameObject > Mania Map > Generation Pipeline.
  2. Select the child <Inputs> Game Object and add any layout graphs and collectable groups you wish to associate with the generator to the inputs.

Generation Pipeline

  1. To run the pipeline and generate a layout, run the Run method from a script.
var results = Pipeline.Run();

// Retrieve the generated layout data from the ouput results
var layout = results.GetOutput<Layout>("Layout");

About

Procedural generation of metroidvania style maps for Unity.

Topics

Resources

License

BSD-3-Clause, Unknown licenses found

Licenses found

BSD-3-Clause
LICENSE
Unknown
LICENSE.meta

Stars

Watchers

Forks

Languages