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
- Ensure PlayMaker is successfully installed and operational in your project.
- Navigate to
Assets/DunGen/Integration/in your Project view. - Double-click the
PlayMaker.unitypackagefile 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 Dungeoncomponent in the scene. - Usage:
- You must have a GameObject in your scene with a
Runtime Dungeoncomponent already set up (with a Dungeon Flow asset assigned, etc.). - In the PlayMaker action settings, specify the GameObject that contains this pre-configured
Runtime Dungeoncomponent. - This action is useful when you prefer to manage your main generation settings directly on a component in the scene hierarchy.
- You must have a GameObject in your scene with a
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 Flowasset, randomization seed, etc.) within the action's properties in the PlayMaker Editor. - You do not necessarily need a pre-existing
Runtime Dungeoncomponent in the scene; if the specified target GameObject doesn't have one, this action can create one for you. - Optional
Runtime DungeonParameter: You can still specify a GameObject with an existingRuntime Dungeoncomponent. 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.
- Configure the desired settings (like the
Clear
- Description: Removes/destroys a previously generated dungeon layout associated with a specific
Runtime Dungeoncomponent. - Usage:
- Specify the GameObject that currently holds the
Runtime Dungeoncomponent 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.
- Specify the GameObject that currently holds the
Basic Usage Example
You could create a simple FSM on a GameManager object:
- Start State: Waits for a trigger (e.g., "Start Game" event).
- Generate Dungeon State: Uses the
GenerateorGenerate with Settingsaction to create the dungeon. Stores the GameObject containing theRuntime Dungeoncomponent in a variable if needed for clearing later. - Gameplay State: The game proceeds.
- (Optional) Clear Dungeon State: Triggered by an event (e.g., "Exit Level"). Uses the
Clearaction, 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.