Skelitten Games

Generating and Loading Dungeons

Generating and loading a dungeon are two separate steps:

  • The Dungeon Generator Component generates the layout. It chooses the modules and where they should be placed.
  • The Dungeon Spawner Component loads the module levels at those positions.

Setting Up the Game Mode and Game State

  1. Open your Game Mode.
    • If you are using the plugin in a replicated environment, reparent your Game Mode to Dungeon Game Mode or Dungeon Game Mode Base. These handle loading the dungeon for players who join later.
    • If don't need replication, add a Dungeon Generator Component to your Game Mode.
  2. Open your Game State (or create one) → Add a Dungeon Spawner Component.
    • If you are using a (Dungeon) Game Mode Base, make sure your Game State inherits from Game State Base. The same goes for the non-base version, make sure that you are using the same for your Game Mode and State, otherwise your game won't launch anymore.
  3. Open your Game Mode → Set Game State Class to the Game State you set up.
  4. Select your Game Mode under Project Settings → Default Game Mode or World Settings → Game Mode Override.

Generating the Dungeon

In your Game Mode:

  1. Select the Dungeon Generator Component → In the Details panel under Events, add On Generation Finished and On Generation Failed.
  2. On Begin Play → Call Generate Dungeon on the generator component.
    • Select your Dungeon Graph and Module Set.
    • Origin is the starting position and rotation in the world.
    • Seed defaults to -1, which picks a random seed. You can use a fixed seed when working on a particular layout.
  3. Optional: When On Generation Failed runs → Print the Reason and Message. If Debug Mode is enabled (Dungeon Generator Component Settings), the reason and message will always be printed.

Use this setup to print the Reason and Message.

There are three ways to generate a dungeon:

  • Generate Dungeon: Generates a dungeon where the given origin is equal to the origin of the first module placed. Use this if you want to generate a dungeon and teleport the players inside.
  • Generate Dungeon at Connector: Generates a dungeon that is attached to the given connector. Use this if you already have a dungeon, and you want to attach a dungeon to any of its external connectors. See Chaining Dungeons for more information.
  • Generate Dungeon at Entrance: Generates a dungeon that is attached to the given entrance transform. This is very similar to Generate Dungeon at Connector, but allows you to attach to any given transform (it does not require a connector). Use this if you have a door or gate of some kind in your level that should lead into a dungeon.

Example for how to use Generate Dungeon at Connector.

Loading the Dungeon

When On Generation Finished runs → Call Load Dungeon on the generator component and pass on the Dungeon ID.

Use the following events to know when the dungeon has loaded:

  • On Local Dungeon Loaded, on the spawner, runs when the modules, Connector Actors, and Module Managers are ready on this machine.
    • Use this event if you want to find or modify a module or its actors after it has been loaded in.
  • On Dungeon Loaded, on the generator, runs when loading has finished on the server.
    • Clients might still be loading.
  • On Dungeon Loaded For All Players, on the generator, runs when the server and all connected players have finished loading.
    • This event can run again after a new player joins and finishes loading.

These events do not wait for navigation to finish building or any extra gameplay setup you added.

Unloading or Removing a Dungeon

Call these functions on the Dungeon Generator Component and pass the dungeon's Dungeon ID:

  • Unload Dungeon removes the module levels from the world, but keeps the generated layout.
    • You can call Load Dungeon to load the same layout again.
    • The layout still takes up space when Check Other Dungeons is enabled.
  • Remove Dungeon removes the layout and frees its space.
    • If the dungeon is still loaded, it will be unloaded first.

Generation, loading, unloading, and removal run in the order you request them.

Troubleshooting

  1. On your Game Mode → Dungeon Generator Component → Turn on Enable Debug, then try again.
    • Make sure your Module Set has modules of every type used in the Dungeon Graph.
  2. Add On Generation Failed to your Game Mode graph → Print the Reason and Message.
  3. If generation finishes but the dungeon doesn't load:
    • Make sure you call Load Dungeon with the correct Dungeon ID.
    • Make sure the active Game State has a Dungeon Spawner Component.
    • Use On Local Dungeon Load Failed on the spawner → Print the Message.

Search documentation

Type to search all documentation.