Skip to content

Integrations: PlayMaker

DunGen offers basic integration with Hutong Games' PlayMaker, a popular visual scripting tool for Unity. This allows you to control DunGen's dungeon generation process directly from your PlayMaker Finite State Machines (FSMs) without needing to write traditional C# code.

Third-Party Asset Required

PlayMaker is a separate asset available on the Unity Asset Store and must be purchased and imported into your project before setting up this integration.


Setup

  1. Ensure PlayMaker is successfully installed and operational in your project.
  2. Navigate to Assets/DunGen/Integration/ in your Project view.
  3. Double-click the PlayMaker.unitypackage file to import its contents into your project.

Once imported, you should find new DunGen-specific actions available in the PlayMaker Action Browser.


Available PlayMaker Actions

Currently, DunGen provides the following PlayMaker actions:


Generate

  • Description: Generates a new dungeon layout using the settings configured on an existing Runtime Dungeon component in the scene.
  • Usage:
    • You must have a GameObject in your scene with a Runtime Dungeon component already set up (with a Dungeon Flow asset assigned, etc.).
    • In the PlayMaker action settings, specify the GameObject that contains this pre-configured Runtime Dungeon component.
    • This action is useful when you prefer to manage your main generation settings directly on a component in the scene hierarchy.

Generate with Settings

  • Description: Generates a new dungeon layout using settings specified directly within the PlayMaker action itself.
  • Usage:
    • Configure the desired settings (like the Dungeon Flow asset, randomization seed, etc.) within the action's properties in the PlayMaker Editor.
    • You do not necessarily need a pre-existing Runtime Dungeon component in the scene; if the specified target GameObject doesn't have one, this action can create one for you.
    • Optional Runtime Dungeon Parameter: You can still specify a GameObject with an existing Runtime Dungeon component. If you do, the settings from the action will be used primarily, but any settings on the component not directly exposed in the PlayMaker action (like attached adapters, specific overrides, root object) will still be respected.
    • This action is useful for more self-contained generation logic within your FSM, requiring less initial scene setup.

Clear

  • Description: Removes/destroys a previously generated dungeon layout associated with a specific Runtime Dungeon component.
  • Usage:
    • Specify the GameObject that currently holds the Runtime Dungeon component whose generated dungeon you want to clear.
    • This is typically used before generating a new dungeon layout to clean up the old one, or when transitioning away from the level.

Basic Usage Example

You could create a simple FSM on a GameManager object:

  1. Start State: Waits for a trigger (e.g., "Start Game" event).
  2. Generate Dungeon State: Uses the Generate or Generate with Settings action to create the dungeon. Stores the GameObject containing the Runtime Dungeon component in a variable if needed for clearing later.
  3. Gameplay State: The game proceeds.
  4. (Optional) Clear Dungeon State: Triggered by an event (e.g., "Exit Level"). Uses the Clear action, referencing the stored GameObject variable, to remove the dungeon before loading a new scene.

By using these actions, you can integrate DunGen's procedural capabilities into your projects using PlayMaker's intuitive visual scripting interface.