Skip to main content

Configuration

This page contains a list of all the properties that can be configured on the Walker Generator component. This is NOT a good place to start your journey with Frigga. You should first at least watch the Getting Started video. The generator comes with a sensible default configuration so you can usually most of the fields intact.

General

This section contains the general configuration of a procedural level generator.

Theme

The Theme that is used after a layout is generated. This field is mandatory.

Output

References the game object that contains the generated level. This field can be left empty and a new game object will be created for you after you generate the first level. In case you need to customize the structure of the generated level, you can refer to the Customize output page.

Generate On

Configures when a new level should be generated. By default, it is set to Awake which means that a level is automatically generated during Awake() when a scene gets loaded. It can also be set to Start or Manually. When set to Manually, no level will be generated automatically and you need to use the scripting API.

The manual approach is recommended for production purposes when working with loading screens and similar, while the automatic approach is great for prototyping because you do not need any extra code to run the generator.

Seed

Random generator seed to be used when generating a new level. Using the same seed leads to two identical levels being produced, which can be useful for save system or multiplayer purposes.

Use Random Seed

Whether a random seed should be generated each time the generator is used. When set to true, the Seed field is ignored.

Auto Refresh Theme

When enabled, the theme of a level is automatically refreshed when a change is made to it in the editor.

Animation Speed

The speed of the animation when running the generator in an animated mode. How many ms to wait between the steps of the generator.

Show Gizmos

Whether to show generator gizmos, for example, the positions of individual walkers when animating the progress.

Walker - General

This section contains the general configuration of the walker algorithm.

Fixed Level Size

Configures whether the level has a fixed-size frame to fit into or not. If enabled, each level must fit into an N by M frame defined below when a specified ratio of floor tiles is achieved. If disabled, the level is not bound by any fixed frame and the generator is stopped only after a specified number of floor tiles is used.

tip

Setting Fixed Level Size to true usually leads to more dungeon-like levels because the generator is forced to use a specified bounding box, forcing the walkers to come back to already explored parts of the level, making passages that lead back to the level. The disadvantage of this configuration is that the frame is apparent in the generated level because you can see a long straight wall.

Setting Fixed Level Size to false usually leads to more organic shapes because there is no invisible wall that the walker can bump into into. This can lead to shapes similar to island or continents.

Level Size

Configures the size of a frame into which each generated level must fit. Is used only when Fixed Level Size is enabled.

note

Border Size is always applied on top of the level size. That means that if Level Size is set to 60x40 and Border Size is set to 10, the size of the generated tilemap will be 80x60.

Fill Ratio

Configures the target ratio of floor tiles versus wall tiles. Is used only when Fixed Level Size is enabled. The generator will run until this ratio is fulfilled. A good default value is around 0.3, or 30%. If set too high, the generator might not be able to produce such a level and will stop after Max Iterations no matter whether the ratio was reached or not.

Target Tile Count

Configures how many floor tiles should be placed before the generator finishes. Is used only when Fixed Level Size is enabled.

Border Size

Configures a border made of walls that are added around the whole level. You can use this to make sure that the player is never too close to the level border.

note

Border Size is always applied on top of the level size. That means that if Level Size is set to 60x40 and Border Size is set to 10, the size of the generated tilemap will be 80x60.

Floor Tile and Wall Tile

These two fields are mandatory and provide a mapping between tiles that are defined in the Theme and tiles that the Walker generator understands. The names of the tiles do not need to match with your Theme tiles. It is only important that Floor Tile is the tile that is meant to be walkable in your Theme and the other tile is the non-walkable tile.

For example, if you are making a dungeon, you might already have a Floor tile and a Wall tile. But if you are making a procedural island, you might have a walkable Ground tile and a non-walkable Water tile. In that case, you would assign Ground to Floor tile and Water to Wall tile.

Max Iterations

Limits the maximum number of iterations the generator is allowed to do before stopping. It is possible to configure the walker algorithm in a way that would keep the algorithm running infinitely, so the Max Iterations field provides a way to prevent that. Keep in mind that if the maximum number of iterations is reached, the generator will stop no matter if the level is complete.

Minimum Wall Size

This is a very important parameter that controls the minimal size of wall chunks that are allowed in a level. For example, if the minimum wall size is set to (2,3), it means that whenever there is a wall tile placed in the level, it must be part of a larger chunk of wall tiles according to the minimum size. Each tileset has different requirements for the wall sizes so make sure to set it appropriately.

note

The larger the Minimum Wall Size is, the more open space levels will be generated. Minimum Wall Size is enforced in a post-processing step which removes all nonconforming walls from the level, leading to levels with more open space areas.

Center Grid

Whether to reposition the level so that the center of the level is placed at (0,0,0). This is mostly useful for prototyping purposes when Fixed Level Size is set to false because the levels tend to jump all over the place depending on which directions the algorithm chooses to expand the level.

Walker - Path making

This section deals with the configuration of the path-making algorithm. Inside the algorithm, there is a population of walkers where each walker is an entity that moves around the level and wherever it moves it spawns a floor tile. During each step of the algorithm, each walker can do the following:

  • it always moves forward if not already on the border of the fixed frame
  • it can rotate right/left/backward
  • it can spawn another walker at the same position (up to a specified limit)
  • it can die (as long as there is at least a single walker)
  • it can decide to spawn more than one floor tile

Rotation Chance

The probability that the walker rotates after making a step forward during each step of the generator.

Rotate Right Weight, Rotate Left Weight and Rotate Backward Weight

Configures the weight for a specific rotation of the walker. After each step of a walker, we first roll a dice to see whether a walker should rotate, and if it should, we choose a random rotation according to the weights.

Let's have this scenario:

  • Rotate Right Weight is 2
  • Rotate Left Weight is 1
  • Rotate Backward Weight is 0

The walker will never rotate backward because the weight is set to 0, and on average, the walker will rotate right twice as often as left.

Max Steps Without Rotation

How many steps forward at most is each walker allowed to do before being forced to rotate.

Max Walker Count

Configure the maximum number of walkers that can exist at the same time. After this count is reached, no more walkers will be spawned.

Walker Spawn Chance

The probability that an existing walker will duplicate to create a new walker. The new walker will spawn at the same position as the original one.

Walker Death Chance

The probability that a walker will die after making a step.

Spawn Chunk Chance

It is possible to spawn more than one tile after each step of a walker. This field configures the chance of spawning more than one tile.

Spawn 2x2 Chunk Weight and Spawn 3x3 Chunk Weight

The weight for spawning a 2x2 floor chunk or a 3x3 floor chunk under the feet of the walker. Is only used if Spawn Chunk Chance is larger than 0.

Walker - Spawn and Exit

In this section, we can configure that the generator should spawn specified points of interest, in this case, a Spawn point or an Exit point. Both the Spawn point and the Exit point have the same configuration so let's talk just about the Spawn point here. All points of interest are placed on top of Floor tiles.

Enabled

Whether the Spawn point should be generated.

Place In Center

Whether the Spawn point should be placed somewhere in the center of the level. If set to false, the generator will put it in one of the corners of the level.

Open Space

Whether the generator should attempt to find a tile that is not right next to a wall tile. This is useful for some tilesets where the tile right next to a wall tile is reserved for some special graphics.

Tile

Which int grid tile should be placed on the Spawn point.

note

This is optional but very useful because if we keep this field undefined, an ordinary floor tile will be used, and a decoration can be spawned on top of it. If we want to place a player on the spawn point, the player will be placed on top of the decoration, which is not desired. Therefore, it makes sense to create a special Spawn tile instead and make it so that no decorations can be placed on top of it. Then we can be sure that the tile is ready for our player object.

Game Object

Whether we want to place a game object on top of the Spawn point. The game object can be a prefab or an object from the scene. If it is a prefab, you must also check the Instantiate field.

note

This can be very useful for placing the player object or an exit point like a ladder to the next dungeon floor.

Instantiate

Whether the Game Object should be instantiated or not. If it is a prefab, this field must be enabled. If the game object comes from the scene, we can choose whether we want to instantiate a new copy or not.

note

If we want to place the player on top of the spawn point, it is best to have it inside the scene and disable the Instantiate field. That way you keep only a single instance of the player of the object so you can use it in other tools like Cinemachine.

Events

On Level Generated

Callback that is triggered once a level is generated. The callback function gets passed information about the generated level. Example script:

using Frigga;
using UnityEngine;

public class PostProcessing1 : MonoBehaviour
{
public void OnLevelGenerated(GeneratorResult result)
{
Debug.Log("The level was generated!");
Debug.Log($"The Theme that was used is named {result.Theme.name}");
}
}