Dungeon Architect for Unity 1.20 Help

Placeable Markers

In this section, we'll spawn items like NPCs, power ups etc in our dungeon.

For this, we'll do the following:

  • Use the Spawn Item node in the flow graph. This will add items in the layout graph

  • Create Placeable Marker assets and drop a few of them in the snap modules so that the builder can spawn them at those places when necessary

  • Use the Theme engine to spawn the actual prefabs at those marker locations

Spawn Items in Flow Graph

Open up our flow graph editor and reassign the Module database in the Editor Settings, as we've done previously

Ut 09 48
  1. Create a new Spawn Items node and link it up as shown below:

Ut 10 01
Ut 10 02
  1. Select the Spawn Items node and inspect the properties.

Ut 10 03
  1. We want to spawn enemies in the main path (green) and the alt path (orange).

    • Add two entries to the Paths array and set the values to main and alt

    • Set the Item Type to Enemy

    • Set the marker name to Grunt. Later in the theme file, we'll create a marker node named Grunt and place our NPC prefabs under it

Ut 10 04
  1. Rebuild the flow graph

Ut 10 05

The nodes now in the green path (main) and orange path (alt) have red enemy items

  1. Add a description to this node

    Ut 10 06
    Ut 10 07

Placeable Markers

A placeable marker is an prefab you create, which you can then drag and drop anywhere on your modules. You can then use the theme file to spawn objects at that location.

A placeable marker prefab can contain more than one marker name. For example, a placeable marker prefab named PM_Enemies may contain a list of marker names like (Grunt, FireTroll, IceTroll, Goblin). In your snap module, you'd place these markers in appropriate locations (say 10 different locations within the room module).

If the dungeon builder needs to spawn a Grunt marker 4 times inside the room, it will first find all the existing and compatible marker assets placed in the room. In this case PM_Enemies would be compatible since it contains a Grunt marker. Since we have 10 of these in the room module, it will randomly pick 4 from them and use the theme file to spawn the grunt prefab

Create Prefab

  1. Move to an appropriate folder and create a Placeable Marker prefab from the create menu

    Ut 10 08
  2. Rename it to PM_Enemies

    Ut 10 09
  3. Select the PM_Enemies prefab and inspect the properties. Add a Grunt marker (since we specified this earlier in the Spawn Items node). Add a few more markers for future use like IceTroll, FireTroll, Goblin

    Ut 10 10

Add to Snap Modules

Open up the previously created room module

Ut 10 11
Ut 10 12
Ut 10 13

We went ahead and added a bit of geometry int he room

Ut 10 18

The snap system gives complete freedom to the artist to design the room as they see fit. In that same spirit, the artist should also have control on where the markers spawn. This is where placeable markers come in

Drag drop the placeable marker prefab that you've created before, on to the scene

Ut 10 14

This will spawn a placeable marker game object on the scene. When selected, it shows the descripton (Debug Text) of the placeable marker.

Ut 10 15

Rotate the actor as needed. The red arrow shows the orientation of the marker. When the theme engine spawns an actor here, it will do so with this rotation

Ut 10 16

Add a few more markers. Add at least 4 markers, since we are adding a maximum of 4 enemy items per node in the flow graph using Spawn Item, but adding more is always better

Ut 10 17

We'll add a few more on top of the ramp

Ut 10 19
Ut 10 20

Do this for all the modules you've created so far that would need this marker in it

Open up the Lift module and add a few more placeable markers there

Ut 10 21
Ut 10 22
Ut 10 23
Ut 10 24

Open up the 2x1x1 and 2x2x2 Room modules and add the markers there as well

Ut 10 39
Ut 10 40

Rebuild Module Database Cache

If you add / remove a placeable marker from a snap module, you'll need to rebuild the module database cache

Select the Module database asset that we created in the previous section and in the inspector, click Build Module Cache button. Save the module database asset

Ut 10 25
Ut 10 26

Update Theme File

We'll use a theme file to actually spawn our enemy prefab.

Open Theme Editor

Open up the existing theme file we created in the previous section.

Ut 10 27

Double click on the theme asset to open the theme editor

Ut 10 28

Box select all the marker nodes and delete them

Ut 10 29
Ut 10 30

Create Marker

In the previous section, we assign the marker name of Grunt in the Spawn Items node. In the theme file, we'll create a new marker node and name it Grunt

Right click on the graph and choose Add Marker Node

Ut 10 31

Select the marker node and from the inspector, change the Marker name to Grunt

Ut 10 32
Ut 10 33
Ut 10 34

Add Enemy prefab

Add your NPC character prefab here. For this tutorial, we'll add a cube and adjust the size and scale

Navigate to Assets > CodeRespawn > DungeonArchitect_Samples > Demo_Theme_SimpleShapes > Prefabs and drop in Cube_Red and connect it the Grunt marker node to it

Ut 10 35

Select the cube node that you just dropped and adjust the scale and position

Ut 10 36

Save and close the Theme Editor

Build Dungeon

Open the map where we previously configured our dungeon and build it.

You'll see that enemies start to spawn at the locations where you've placed the markers

Ut 10 37
Ut 10 38

You can use this system to spawn anything (treasure chests, weapon racks, power ups or any gameplay prefab)

Last modified: 24 January 2024