Dungeon Architect User Guide 01
01%20User%20Guide%20-%20Dungeon%20Architect
01%20User%20Guide%20-%20Dungeon%20Architect
01%20User%20Guide%20-%20Dungeon%20Architect
01%20User%20Guide%20-%20Dungeon%20Architect
User Manual: Pdf
Open the PDF directly: View PDF .
Page Count: 100
Download | ![]() |
Open PDF In Browser | View PDF |
Dungeon Architect User Guide for Unity 5 1 Introduc on Dungeon Architect is a plugin for Unity that helps in streamlining the level crea on process. It allows you to quickly create levels procedurally (or manually) by blocking out volumes and having the plugin build the environment automa cally around it. This document introduces you to the various features of Dungeon Architect 2 Genera on Overview A dungeon is generated in two phases • Layout Genera on • Visual Genera on 2.1 Layout Genera on In this phase, only the layout of the dungeon is generated in memory. No meshes or actors are actually spawned. Next, the level is populated with invisible points called Markers around the generated layout. A marker has only a name and a transforma on in the 3D space. In the above image, a er the layout has been built, the dungeon builder has populated the level with marker points around the layout of the dungeon 1 Figure 1: Architecture 2.2 Visual Genera on This phase spawns the actors in your scene. It takes all the marker points inserted in the previous phase and replaces them with actors (meshes, lights, blueprints etc) that you have mapped in your theme files The theming engine is executed for each marker inserted in the Layout genera on phase. In the above example, when a Ground marker is encountered, it would look for a Ground marker mapping in your theme file and replace the marker with the meshes you have mapped to it The advantage of this data driven theme based approach is that theme files can be swapped to give your dungeon a completly different look. Theme files can also be shared across mulitple projects / teams Mul ple themes can also be used within the same dungeon to create varia ons 3 Dungeon Prefab A dungeon prefab is used to build your dungeons. Dungeon Architect supports building dungeons with different layouts. The current supported ones are Grid, SimpleCity and 2 Figure 2: Layout of the dungeon in memory 3 Figure 3: Markers populated for a sample room 4 Figure 4: Actors spawned by a theme mapping 5 Figure 5: Sample Theme Mapping Figure 6: Result a er theme mapping 6 Floorplan. Drop the appropriate dungeon prefab into the scene and reset its transform Figure 7: Dungeon Prefab The dungeon game object generate a procedural layout for your dungeon based on the various configura on paramters. A er the layout has been generated, it spawns meshes, lights, blueprints etc, based on the mappings you have defined in the Theme file. This way you can define what meshes needs to be a ached to the floors, walls, ceilings, etc 3.1 Proper es The Dungeon game object lets you perform various ac ons on your procedural dungeon. Select the Dungeon game object and have a look at the configura on in the Inspector window Build Dungeon: Builds a procedural dungeon. You need to define atleast one theme before you build Destroy Dungeon: Destroys an exis ng dungeon owned by this actor. If you want to rebuild a dungeon a er modifying the theme, there is no need to destroy first and you can directly click build Themes: A theme file lets you design the look and feel of your dungeon. The theme editor lets you interac vely design your own themes. You need to specify atleast one theme file before you can build your dungeon (sample content comes with many precreated themes to get you started) Debug Draw: Draws debug informa on in the scene view 7 Figure 8: Dungeon Actor Proper es 3.2 Config Parameters Select the Dungeon Actor and navigate to the Inspector window The various config parameters determine how the layout of the dungeon is generated procedurally. The default layout generator algorithm is implemented based on the excellent writeup by TinyKeep’s author Phi Dinh The various parameters are: • Seed: Changing this number would completely change the layout of the dungeon. This is the base random number seed that is used to build the dungeon. There is a convenience func on to randomize this value (bu on labeled R) • Num Cells: The number of cells to use while building the dungeon. You will not see these cells in the final result. A larger number would create a bigger and more complex dungeon. A number of 100-150 builds a medium to large sized dungeon. Experiment with different ranges • Grid Cell Size: The dungeon generator works on a grid based system and required modular mesh assets to be placed on each cell (floors, walls, doors etc). This important field specifies the size of the cell to use. This size is determined by the art asset used in the dungeon theme designed by the ar st. In the demo, we have a floor mesh that is 400x400. The height of a floor is chosen to be 200 units as the stair mesh is 200 units high. Hence the defaults are set to 400x400x200. 8 Figure 9: Dungeon Config Parameters 9 You should change this to the dimension of the modular asset your designer has created for the dungeon • Min/Max Cell Size: This is how big or small a cell size can be. While genera on, a cell is either converted to a room, corridor or is discarded completely. The Cell width / height is randomly chosen within this range • Room Area Threshold: If a cell size exceeds past this limit, it is converted into a room. A er cells are promoted to rooms, all rooms are connected to each other through corridors (either directly or indirectly. See spanning tree later) • Room Aspect Delta: The aspect ra o of the cells (width to height ra o). Keeping this value near 0 would create square rooms. Bringing this close to 1 would create elongated / stretched rooms with a high width to height ra o • Corridor Padding: The extra width to apply to one side of a corridor • Corridor Padding Double Sided: Flag to apply the padding on both sides of the corridor • Height Varia on Probability: Tweak this value to increase / reduce the height varia ons (and stairs) in your dungeon. A value close to 0 reduces the height varia on and increases as you approach 1. Increasing this value to a higher level might create dungeons with no place for proper stair placement since there is too much height varia on. A value of 0.2 to 0.4 seems good • Max Allowed Stair Height: The number of logical floor units the dungeon height can vary. This determines how high the dungeon’s height can vary (e.g. max 2 floors high). Set this value depending on the stair meshes you designer has created. In the sample demo, there are two stair meshes, one 200 units high (1 floor) and another 400 units high (2 floors). So the default is set to 2 • Spanning Tree Loop: Determines how many loops you would like to have in your dungeon. A value near 0 will create fewer loops crea ng linear dungeons. A value near 1 would create lots of loops, which would look unoriginal. Its good to allow a few loops so a value close to zero (like 0.2 should be good) • Stair Connec on Tolerance: The generator would add stairs to make different areas of the dungeon accessible. However, we do not want too many stairs. For e.g., before adding a stair in a par cular elevated area, the generator would check if this area is already accessible from a nearby stair. If so, it would not add it. This tolerance parameter determines how far to look for an exis ng path before we 10 can add a stair. Play with this parameter if you see too many stairs close to each other, or too few • Normal Mean / Std: The random number generator used in the dungeon generator does not use a uniform distribu on. Instead it uses a normal distribu on to get higher frequency of lower values and fewer higher values (and hence fewer room cells and a lot more corridor cells). Play with these parameters for different results • Ini al Room Radius: Internal Usage. Keep to a low value like 10-15 4 Theme Overview A theme file lets you design the look and feel of you dungeons with an intui ve graph based approach Themes are saved as a separate assets on disk. Dungeon Architect also provides an interac ve editor to help you design beau ful levels Figure 10: An example theme 11 Figure 11: Themes are used by the Theming Engine 4.1 Create a Theme To create a new theme, right click in the content browser and choose “Dungeon Theme” 5 Theme Editor Double click a dungeon theme asset to open it in the Theme Editor 5.1 Interac ve Edi ng As you design your theme, the scene view automa cally gets updated based on your theme graph mapping. To make this happen, you need to have a dungeon game object in the scene with the current theme being edited applied to it Whenever you change the theme, the theme editor would search for a dungeon game object in the scene (that has this theme applied to it) and rebuild it. This way, you get an immediate visual feedback while designing the look and feel of you levels 12 Figure 12: Create a dungeon theme 13 Figure 13: Dungeon Theme Asset Figure 14: Dungeon Architect Theme Editor Figure 15: Dungeon Architect Theme Editor 14 6 Theme Nodes A Theme can have 3 category of nodes • Marker Nodes • Visual Nodes • Marker Emi er Nodes Figure 16: Theme Node categories 15 6.1 Marker Nodes A er the layout genera on phase, the scene would be sca ered with invisible named points called Markers. Then, for every marker point in the scene, the theming engine looks for a corresponding Marker Node with that marker name. If found, it would start execu ng all the nodes defined below the marker node. For e.g., if you have a marker node named Ground, it would be invoked for every Ground marker found in the scene. Once invoked, the theming engine executes all the nodes defined below it from le to right un ll a certain condi on is met Figure 17: Ground Node 16 In the above example: 1. In the first phase, the layout builder has populated the map with ground markers, wherever a ground mesh was expected. 2. Then in the next phase, the theming engine ecounters the Ground marker while itera ng through all the markers in the scene 3. It then looks for a Marker Node named Ground in the theme graph 4. Once found, it executes the visual nodes defined below it, star ng from le to right When you create a new theme asset, the theme graph comes with a set of default marker nodes. You can define new marker nodes and build your own hierarcy for advanced theming Names of custom marker nodes can be changed by double clicking on them, or from the details tab 6.1.1 Crea ng marker nodes To create a marker node, right click anywhere in the empty area and choose Add Marker Node 6.2 Visual Nodes Visual nodes are used for spawning visual objects into the scene (e.g. any game objects, sprites etc). They are usually a ached to a marker node and executed whenever an marker with that name is encountered in the scene. When executed, it spawns a game object defined within it and places it in the scene where the marker was encountered You can create the following visual nodes: • Game Object Node - Spawns any type of a game object. Expects a game object template (e.g. prefabs) • Sprite Node - Spawns a sprite for your 2D games. Expects a sprite reference. Also have sprite specific proper es 17 Figure 18: Add new marker node from the Context Menu 18 6.2.1 Crea ng visual nodes There are several ways to create a new visual node: Drag and drop a game object from the Project window on to the theme editor to create a Game Object or Sprite node Figure 19: Drag an drop prefabs into the theme editor Alterna vely, drag a link out of the marker node you intend to a ach it on and select the appropriate visual node you desire Then select the node and assign the game object template from the inspector window 6.3 Marker Emi er Nodes Marker Emi ers emit new markers into the scene. These nodes are a ached to visual nodes and if the parent visual node is executed, it would insert a named marker into the scene. Marker Emi er nodes are similar in apperarance to Marker Nodes. However, they are purple in color and have an input pin, instead of an output pin In the above example, the Wall Marker has 3 Mesh nodes a ached to it with probability such that any one for the 3 would be randomly chosen. One of the 3 meshes has a window in it and we would like to decorate that mesh with 19 Figure 20: Drag a link from exis ng marker nodes 20 Figure 21: This would create an empty visual node curtains, but only if that node is selected. So, we define a new Marker named Curtains (can be any name) and a ach curtain meshes to it. Then we emit a Curtain Marker Node from the desired visual node. Hence, if the mesh in the middle is executed, it would also insert a marker named Curtain in its posi on. Then the theming engine would execute everything beneath the Curtain marker and pick a random curtain and a ach to the wall This ability of defining your own hierarchy lets you design powerful themes for your levels 6.3.1 Crea ng marker emi er nodes To create a Marker Emi er Node, drag a link out of a visual node and select a marker name you would like to emit Alterna vely, right click anywhere in the empty area and expand the Marker Emitters category and click choose a marker to emit You can create a marker emi er for any of the exis ng markers in the scene 21 Figure 22: This would create an empty visual node 22 Figure 23: Marker Emi er Sample 6.3.2 Cycles Cycles are not allowed when you emit markers since we do not want to con nuously emit markers in an infinite loop The editor takes care of not allowing cycles and no fies you with a user-friendly message when you a empt to create a connec on with a marker emi er that might cause a loop 7 Theme Node Proper es A node in the theme graph can be customized from the Details Tab 7.1 Visual Nodes Select a visual node (e.g. a Game Object node) and have a look at the details tab: 23 Figure 24: Sample Dungeon Scene 24 Figure 25: Choose a Marker to emit from the filtered context menu 25 Figure 26: Choose a Marker to 26emit from the context menu Figure 27: Cycles not allowed 27 Figure 28: Game Object Node proper es 28 The proper es that are common to all Visual nodes (Game Object, Sprite etc) are explained below: Offset: Apply transforma on offset to your visual object rela ve to the marker loca on. This is a very useful property while designing your theme. If the pivot of the mesh your ar st has designed isn’t where you wish it were, you can easily adjust it here to translate / rotate it around. You can also scale objects if they are too small / big. While designing your theme, you’ll find this property useful to re-posi on your visual nodes, if required. Probability: This is the probability of a achment. When this node is executed, the theming engine looks at this variable and rolls a dice and decides whether to insert this visual object into the scene or not. If this value is 1.0, then it would insert it 100% of the me. If the value is 0, then it would not insert it since selec on probability 0%. If it is 0.5, then it would insert it 50% of the me Consume on A ach: If the visual object was indeed spawned into the scene (based on the probability above), the theming engine would then look at this flag to decide if we need to execute the next sibling visual node. If it is checked, then execu on stops for this marker. If it is unchecked, the next sibling gets processed. Affinity and Consume on A ach can be combined to create interes ng possibli es in your theme Selec on Logic: Lets you define selec on logic scripts. You have seen an example above of node selected based on random probability (Probability property). The selec on process can be far more power than a simple random probability based selec on. You can define you own behavior scripts and assign it here so your custom logic can decide if a node is to be selected or not. More details below Transform Logic: In the Offset property as seen above, you can define a sta c offset transforma on to move/scale/rotate the visual object from the marker posi on. With Transform Logic, your behavior scripts can provide dynamic tranform offsets based on a logic. For e.g., you might want to rotate/scale/translate a tree randomly to give natural varia on instead of having them all face the same direc on. More on this later 7.1.1 Game Object Node A game object not lets you instan ate any type of game object on the scene Template: Specify a game object template (prefab) to spawn in the scene. The node’s thumbnail will update to reflect the game object assigned here 29 Figure 29: Game Object Node specific proper es Sta c: Set this if you want to make your object sta c. If you are spawning dynamic objects (like NPCs), then uncheck this flag 7.1.2 Sprite Class Node If you are making a 2D game, you’ll use Sprite nodes to build your scene Here are the sprite specific parameters: Sprite: Assign the sprite you would like to spawn with this node. The thumbnail of the node displays this sprite, if assigned Color: The color nt to assign on the sprite node Material Override: Specify the different material to use on your sprite (e.g. translucent, masked etc). If unassigned, the default material would be used that is spawned with Unity’s sprite object Sor ng Layer Name: The name of the 2D sor ng layer used with Unity’s 2D framework Order in Layer: The order this mesh should appear in the layer. This value is set in Unity’s 2D sprite object Sta c: Set this if you want to make your object sta c. If you are spawning dynamic objects (like NPCs), then uncheck this flag 7.2 Marker Node You can change the name of a marker node by se ng it’s Name field 30 Figure 30: 2D Procedural Scene 31 Figure 31: Sprite Nodes 32 Figure 32: Sprite Node Proper es Figure 33: Marker Node Proper es 33 7.3 Marker Emi er Node When you emit a marker, you can apply an offset to the emi ed marker in the Offset field Figure 34: Marker Emi er Node Proper es 8 Rules You can a ach script to add logic on the theme nodes for more control. There are two types of rules you can a ach to Visual nodes 8.1 Selec on Rule A selec on rule is a behavior script that is used to decide if the current node is to be a ached to the scene. This rule replaces the default Probability property that is used for randomly deciding if visual node needs spawning based on a probability. Selec on rules gives you more power, when you need it. In the rule’s script logic, you can query the dungeon model and determine if this node should be inserted into the scene 34 Figure 35: Visual Node Rules 35 8.1.1 Using Selec on Rules To assing an exis ng rule into the node, Check the Use Selec on Logic property and drop in the Selec on Rule script you would like to a ach to the node Figure 36: Assign an exis ng Selec on Rule You can create new Selec on Rules by overriding the AlternateSelectionRule class under the DungeonArchitect namespace using UnityEngine; using System.Collections; using DungeonArchitect; public class MySelectionRule : SelectorRule { public override bool CanSelect(PropSocket socket, Matrix4x4 propTransform, DungeonM bool selected = false; // Your selection logic here return selected } } 8.1.2 Example #1 This theme decorates the sides of the walls with props. Some mes, they get in the way and block the doors. A selec on rule is used to query the dungeon model and check if it is near a door. If so, it returns false indica ng that we don’t want to insert it here using UnityEngine; 36 Figure 37: Decora ve props blocking the door pathway 37 Figure 38: Decora ve props removed near doors Figure 39: Rule to avoid crea on of props near doors 38 using using using using System.Collections; DungeonArchitect; DungeonArchitect.Utils; DungeonArchitect.Builders.Grid; public class NonDoorTileSelectionRule : SelectorRule { public override bool CanSelect(PropSocket socket, Matrix4x4 propTransform, DungeonM if (model is GridDungeonModel) { var gridModel = model as GridDungeonModel; var config = gridModel.Config as GridDungeonConfig; var cellSize = config.GridCellSize; var position = Matrix.GetTranslation(ref propTransform); var gridPositionF = MathUtils.Divide (position, cellSize); var gridPosition = MathUtils.ToIntVector(gridPositionF); var cellInfo = gridModel.GetGridCellLookup(gridPosition.x, gridPosition.z); return !cellInfo.ContainsDoor; } else { return false; } } } 8.1.3 Example #2 In this Diablo like dungeon level, the way our camera is setup, we don’t want a room wall to block our view when we are inside a room So we create non-view blocking fences instead of walls at certain wall facing direc ons In the above theme, the rule is a ached to the first node, and if true, it would emit a RoomblockingWall marker which would create a wall and decora ve props. Otherwise, it would proceed to the next node, which emits a Fence marker and would create the fence meshes defined under it This is done with a simple rule that checks the direc on of the wall and decides if the view would be blocked from here using UnityEngine; 39 Figure 40: Rule to disallow wall crea on in the +X and +Z-axis Figure 41: View not blocked by walls 40 Figure 42: Rule assignment to the wall node using System.Collections.Generic; using DungeonArchitect; using DungeonArchitect.Utils; public class NonViewBlockingSelectionRule : SelectorRule { static Vector3[] validDirections = new Vector3[] { new Vector3(1, 0, 0), new Vector3(0, 0, 1), }; public override bool CanSelect(PropSocket socket, Matrix4x4 propTransform, DungeonM var rotation = Matrix.GetRotation(ref socket.Transform); var baseDirection = new Vector3(1, 0, 0); var direction = rotation * baseDirection; foreach (var testDirection in validDirections) { var dot = Vector3.Dot(direction, testDirection); if (dot > 0.707f) return true; } return false; } 41 } 8.1.4 Example #3 In this example the towers are too crowded and close to each other. Figure 43: Towers are too close to each other A selector rule is created to select alternate cells using UnityEngine; using System.Collections; using DungeonArchitect; public class AlternateSelectionRule : SelectorRule { public override bool CanSelect(PropSocket socket, Matrix4x4 propTransform, DungeonM return (socket.gridPosition.x + socket.gridPosition.z) % 2 == 0; } } The above logic uses a checker board pa ern, where you sum the X and Y posi on and return true if it is an even number 42 Figure 44: Select alternate cells Figure 45: Rule assignment 43 8.2 Transform Rule Dungeon Architect lets you specify offsets to your visual nodes to move/scale/rotate them from their rela ve marker loca ons. Figure 46: Sta c node Offset However, if you want a more dynamic way of applying offsets (based on scripts), you can do so with a Transform Rule. This can be very useful to add varia ons to your levels for certain props 8.2.1 Using Transform Rules To assing an exis ng rule into the node, Check the Use Transform Logic property and select the rule you would like to a ach to the transform script You can create new transform rules by implemen ng the TransformationRule class under the DungeonArchitect namespace using using using using UnityEngine; System.Collections; DungeonArchitect; DungeonArchitect.Utils; public class RandomRotYTransformRule : TransformationRule { public override void GetTransform(PropSocket socket, DungeonModel model, Matrix4x4 base.GetTransform(socket, model, propTransform, random, out outPosition, out ou // Your transform logic here. // Update the outPosition, outRotation or outScale if necessary 44 Figure 47: Assigning a Transform Rule 45 } } 8.2.2 Example #1 In this example, the cliff rocks are facing the same direc on and look boring and unnatural Figure 48: Rocks without transform rules using using using using UnityEngine; System.Collections; DungeonArchitect; DungeonArchitect.Utils; public class RandomCliffTransformRule : TransformationRule { public override void GetTransform(PropSocket socket, DungeonModel model, Matrix4x4 base.GetTransform(socket, model, propTransform, random, out outPosition, out ou // Randomly rotate along the Y-axis var angle = random.NextFloat() * 360; var rotation = Quaternion.Euler(0, angle, 0); 46 Figure 49: Rocks randomly rotated and slightly translated Figure 50: Rule assignment on the rock’s base node 47 outRotation = rotation; // Slightly translate the node var variation = new Vector3(0.25f, -1, 0.25f); outPosition = Vector3.Scale (random.OnUnitSphere(), variation); } } A similar rule is applied to trees to randomly rotate them along the Y-axis and randomly scale them slightly 8.2.3 Example #2 In this example, the outer trees are spawned in the same height as the dungeon layout Figure 51: Tree spawned near the dungeon layout However, we also have a terrain that Dungeon Architect modifies, whose steepness value is controlled by the user using a curve. So, we would like to clamp this tree’s base on the dynamic terrain. 48 Figure 52: Proper offset applied to move it to the terrain ground This is done by finding the height of the terrain at that loca on, and crea ng an offset such that the tree would move up or down to properly clamp on it using using using using UnityEngine; System.Collections; DungeonArchitect; DungeonArchitect.Utils; public class ClampToTerrainTransformRule : TransformationRule { public override void GetTransform(PropSocket socket, DungeonModel model, Matrix4x4 base.GetTransform(socket, model, propTransform, random, out outPosition, out ou var terrain = Terrain.activeTerrain; if (terrain == null) { return; } var position = Matrix.GetTranslation(ref propTransform); var currentY = position.y; 49 var targetY = LandscapeDataRasterizer.GetHeight(terrain, position.x, position.z // Apply an offset so we are touching the terrain outPosition.y = targetY - currentY; } } 8.2.4 Example #3 In this example a small random rota on is applied to ground les. Useful while crea ng ruins when laying down broken le meshes Figure 53: Transform rule applied to ground les using using using using UnityEngine; System.Collections; DungeonArchitect; DungeonArchitect.Utils; public class BrokenTilesTransformRule : TransformationRule { 50 public float maxAngle = 5; public override void GetTransform(PropSocket socket, DungeonModel model, Matrix4x4 base.GetTransform(socket, model, propTransform, random, out outPosition, out ou var rx = random.Range(-maxAngle, maxAngle); var ry = random.Range(-maxAngle, maxAngle); var rz = random.Range(-maxAngle, maxAngle); outRotation = Quaternion.Euler(rx, ry, rz); } } 9 Paint Mode Dungeon Architect also allows you to paint your own dungeon layouts with an editor extension. This gives you more ar s c control as you are no longer restricted by what the procedural algorithm creates for you To Ac vate the Paint Editor mode and start pain ng, expand the DungeonGrid game object and select the PaintMode game object. This would change your editor’s scene view into Paint Mode Figure 54: Ac vate Paint Mode When you are in the Paint Mode, the Scene View shows the layout of your dungeon in Blue 51 You can now paint your layout on the Scene View • Le Click: Paint layout • Shi + Le Click: Delete painted layout • Mouse Wheel: Change paint height 52 Figure 55: Star ng Scene Figure 56: Painted cells show up in Cyan color 53 Figure 57: Modifed layout Another Example: 54 55 9.1 Paint Mode Proper es When you select the Paint mode game object, you can set various parameters to control the paint tool: Figure 58: Paint Mode Game Object 56 Figure 59: Paint Mode Proper es 9.2 Non-Procedural Pain ng If you do not want any procedural content to be generated when you paint your level, then set the Num Cells property to 0 in your Dungeon Actor’s Configura on sec on Figure 60: Stop procedural layout genera on This way the dungeon would have an empty layout, allowing you to paint from scratch If you do want procedural content but want to remove certain procedural areas that are ge ng in your way, then use a Nega on Volume 10 Volumes Dungeon Architect provides various volumes to help you influence your dungeon as per your requirements. You can find the various volume prefabs under Assets/DungeonArchtitect/Prefabs 57 Figure 61: Pla orm Volume Prefab 10.1 Pla orm Volume Place a pla orm volume anywhere in the scene and Dungeon Architect would adjust the dungeon layout and create a pla orm (room or corridor) at that loca on. Scale the volume along the XZ plane to change the size of the generated pla orm. You can move the pla orm volume with the move tool to the desired loca on. (Rota on is not supported) This gives you ar s c control and lets you manipulate the dungeon to suit your needs To place a pla orm volume, navigate to Assets/DungeonArchtitect/Prefabs Figure 62: Pla orm Volume Prefab Drag and drop the Pla orm Volume Prefab into the scene view Select the pla orm volume and have a look at it’s proper es 58 Figure 63: Pla orm Volume Prefab Figure 64: Pla orm Volume Proper es 59 The Volume needs to know which dungeon the volume belongs to (DA Supports mulitple dungeons within the same scene). Assign the dungeon you’d like this volume to affect in the Dungeon field Select the type of cell to create on this pla orm’s loca on (Room or Corridor) Corridors form isolated pla orms in the dungeon which merge nicely with exis ng corridor cells Figure 65: Corridor pla orm Rooms always connect to atleast one other room in the dungeon. Changing the Cell type to Room creates this result A bu on to rebuild the dungeon is provided for convenience. It rebuilds the dungeon in the scene 10.2 Theme Override Volume Give certain areas of you dungeons a different look and feel. Layout inside this volume would use the theme defined by this volume. 60 Figure 66: Merges nicely with exis ng procedural layout Figure 67: Volume moved up along the Y-axis 61 Figure 68: Volume moved down along the Y-axis Figure 69: Room pla orm 62 This is useful for adding varia ons to your level Figure 70: Sample Dungeon Select the theme override volume and have a look at it’s proper es Dungeon: Set the dungeon game object this volume should affect Override Theme: Set the dungeon theme asset you would like to apply to the geometry within this volume Note: When overriding, the themes needs to be designed for the same grid cell size for proper results A bu on to rebuild the dungeon is provided for convenience. It rebuilds the dungeon in the scene 10.3 Nega on Volume This volume removes all procedural geometry inside of this volume. Use this to get rid of procedural geometry in areas you do not need or when it is ge ng in the way while manually pain ng your layout 63 Figure 71: Selec ve areas overriden by Theme Override Volumes Select the nega on volume and have a look at it’s proper es Dungeon: Set the dungeon game object this volume should affect A bu on to rebuild the dungeon is provided for convenience. It rebuilds the dungeon in the scene 10.4 Marker Replacement Volume A marker replacement volume replaces marker in the dungeon with your own supplied markers. This is useful if say, you want to replace a wall with a door. You would add a mapping that would replace all the “Wall” markers with “Door” markers. Since this is executed before the theming is applied, this gives you a lot of low level control Check the video for instruc ons on how to use it 64 Figure 72: Geometry within the volume picks up the theme defined by the volume Figure 73: Theme Override Volume Proper es 65 Figure 74: Procedural geometry we’d like to remove 66 Figure 75: Geometry inside the volume removed a er a rebuild Figure 76: Geometry inside the volume removed a er a rebuild 67 View in Youtube 11 Landscape Transformer Dungeon architect can also modify the landscape when it builds the dungeon. Star ng with an empty terrain, it can modify its height and paint it in intres ng ways. Figure 77: Terrain Transformed along the dungeon layout In the above screenshot, a blank terrain was provided as input to the script. It has updated its height (based on a steepness curve provided by the user) and painted the ground, cliffs and pathways with input textures (no ce the organic dirt pathway along the layout) Here’s another Example: 11.1 Usage Navigate to Assets/DungeonArchitect/Scripts/Dungeon/Landscape A ach the script LandscapeTransformerGrid to the Dungeon actor 68 Figure 78: Terrain Transformed along the dungeon layout Figure 79: Landscape Transformer script 69 Figure 80: Landscape Transformer Proper es 70 11.1.1 Terrain Setup Create a new terrain and center it on the dungeon (e.g. set the X and Z to -250). Also move the terrain down along Y by around -20 (an approx lowest point your dungeon layout might reach). This is needed because the height map doesn’t take nega ve values Select the terrain and go to se ngs and set the Control Texture Resolu on 11.1.2 Proper es Terrain: Assign the this terrain reference to the Terrain field in the above script properes Textures: Assign textures to paint the terrain transformer script and the terrain would be painted based on the texture type Ground Level Height: Set the default ground level height of the terrain Layout Level Offset: If set to 0, the terrain would raise up to touch the layout of the dungeon. Some mes you would like this value to be lower, if you already have a ground mesh like the image below Room Eleva on Curve: The curve defines the steepness of the landscape around the rooms Corridor Eleva on Curve: The curve defines the steepness of the landscape around the corridors Assign a preset curve if unassigned for the transformer to work properly Smoothing Distance: The distance to perform the smoothing of the heights using the above curves RoomBlurDistance / CorridorBlurDistance: A smooth pathway is painted on the landscape using blurring algorithms. These fields affect how the smooth corridor pain ng is performed along the rooms and corridors 71 Figure 81: Increase Terrain texture resolu on 72 Figure 82: Landscape Transformer Proper es Figure 83: Landscape touches the layout ground 73 Figure 84: Offset applied to move it down using LayoutLevelOffset 12 Marker Emi er Scripts Marker Emi ers are behavior scripts that lets you emit your own markers anywhere in the map As seen previously, Markers are emi ed by the Dungeon Builder class around the layout of the dungeon (e.g. Wall, Ground, Fence etc) and you can insert actors at that loca on from the Theme graph. You can even create your own markers emi ed off of those parent markers, but without Marker Emi ers you are restricted to the star ng markers the dungeon builder has ini ally emi ed for you Marker Emi ers gives you a lot of flexibility and you can query the dungeon model and emit markers anywhere in the map A Marker Emi er is invoked right a er the Dungeon Builder emits all the markers for the dungeon (Ground, Wall etc) 12.1 Crea ng a Marker Emi er To create a Marker Emi er, you need to create a script inherited from DungeonMarkerEmitter under the DungeonArchitect namespace 74 Figure 85: Offset applied to move it down using LayoutLevelOffset 75 Figure 86: Corridor pathway texture 76 Figure 87: Architecture using using using using UnityEngine; System.Collections; DungeonArchitect; DungeonArchitect.Utils; public class MyAwesomeEmitter : DungeonMarkerEmitter { public override void EmitMarkers(DungeonBuilder builder) { base.EmitMarkers(builder); // Your emitter logic here // Emit as many markers as you like. // Emit a marker like this: // Fill up the marker data var markerName = "MyMarker"; // This name will be picked up in your theme fi var transform = Matrix4x4.TRS(position, rotation, scale); // Additionaly specify the grid based meta data (optional) 77 var gridPosition = new IntVector(); // specify a position value here in grid co var cellId = -1; builder.EmitMarker(markerName, transform, gridPosition, cellId); } } To a ach a marker emi er to your Dungeon game object, simply add this script to the game object Figure 88: Marker Emi ers a ached to the Dungeon Game Object Explore the exis ng marker emi ers that come with Dungeon Architect under Assets/DungeonArchitect/Scripts/MarkerEmitters/Grid 12.2 Example #1 In this example, we’d like to decorate the area outside the dungeon layout that Dungeon Architect has created for us. Since DA creates marker points within the layout, we create a marker emi er to find nearby points in the empty space and emit markers named “EmptySpace_N” where N is 1, 2, 3, 4, 5 etc. These markers are then available to us in the themem file 78 Figure 89: Trees spawned outside the dungeon layout Figure 90: Theme to decorate the markers created by the emi er script 79 12.3 Example #2 Some mes, it’s useful to find the lowest point of the dungeon, so a large plane can be placed there (e.g. water plane, lava plane etc) The MarkerEmitterFindLowestPoint lets you do just that Figure 91: An acid plane created at the bo om of the dungeon This emi er emits a marker named LowestPoint, at the lowest Y point of the dungeon with the appropriate scale, which we can decorate with any object in the theme file 12.4 Example #3 A marker emi er is created to add extra contextual markers to beau fy a 2D level layout (can also be used with 3D) Check the marker named MarkerEmitterCornerBeautifier All the Corner_* markers seen in the theme file above were emi ed by the marker emi er script 80 Figure 92: Node to a ach a plane mesh to this marker Figure 93: Simple layout with a red ground sprite 81 Figure 94: Added decorated sprites with spa al contextual markers Figure 95: Theme to add the decora ve sprites 82 13 Naviga on Mesh Dungeon Architect supports run me naviga on mesh genera on, which is not supported in Unity 5 yet. This is necessary for moving your NPCs intelligently across your procedurally generated level Figure 96: Naviga on This is based on the Recast Naviga on library, so it provides very high quality results. 13.1 Setup To build a naviga on mesh during run me, place the DungeonNaviga on prefab on to your scene Select the game object you just placed and have a look at the inspector window To build the nav mesh, input geometry for walkable and blocked areas needs to be provided. This is done by Triangle Providers There are two types of triangle providers already a ached to the naviga on object 83 Figure 97: Naviga on Prefab • Collision Triagle Provider: Uses the collision mesh of the colliders present in the scene to build the naviga on mesh • Layout Floor Triangle Provider: This provides the floor layout of a dungeon as walkable area to the naviga on mesh input Assign the dungeon reference you would like to use Click Build 13.2 Theme Influence The dungeon objects (meshes, prefabs etc) do not affect the naviga on by default. You need to set the Affects Naviga on flag of the visual node to make it affect the naviga on. The object also has to be sta c in order to affect the naviga on. So the Is Sta c flag also needs to be set. Important: You should set the Affects Naviga on flag only when it is absolutly required to maintain a good nav mesh genera on speed while building 84 Figure 98: Naviga on Proper es Figure 99: Naviga on Triangle Provider 85 Figure 100: Naviga on Proper es Figure 101: Influence Naviga on from Theme Graph Figure 102: Naviga on Genera on Config 86 13.3 Config • Cell Size: Controls the mesh genera on accuracy vs speed. It determines the resolu on of the generated nav mesh. Lowering this number will generate nicer edges and a more accurate navmesh but requires more procesing power and slower. A good value is between 0.2 to 0.3 • Agent Height: The max height of the agents in your game • Agent Radius: The max radius of the agents in your game • Agent Climb Height: The max height an agent can climb on. Objects with height lower than this will not be considered obstacles, as the agent would be able to climb over them • Max Crowd Agents: The max no. of agents that can be present in the game at a me. 13.4 Triangle Providers To generate a naviga on mesh, the nav mesh system requires input triangles so it can build a world and generate the nav mesh. Dungeon Architect comes with various triangle providers to help you affect the nav mesh in various ways. We have seen two of them already above Figure 103: Naviga on Mesh Triangle Providers 87 • Sta cMeshTriangleProvider: Uses the mesh geometry (ver ces, indices) for all the meshes defined in the prefab as a source for the input triangles to generate the nav mesh. This is usually slower but creates detailed results • CollisionTriangleProvider: Uses the colliders defined in the prefab as a source for the input triangles to generate the nav mesh. This is much faster than the StaticMesh triangle provider as it works with the low poly collision geoemtry. However it requires a collider to be present in the prefab to work • TerrainTriangleProvider: Feeds the terrain geometry into the nav mesh generaon system. So you can have your dynamic navmesh build around terrains • LayoutFloorTriangleProvider: Feeds the layout of a dungeon to the nav mesh genera on system. This is usually faster than providing a ground mesh in the CollisionTriangleProvider You can use mul ple triangle providers at once. You can use only the CollisionTriangleProvider for be er performance. However, you can increase the performance even further by disabling the gound mesh from affec ng your naviga on (because there will be lots of ground meshes) and providing that ground data from an addi onal LayoutFloorTriangleProvider script. 13.5 Naviga on Agent Use the NavAgent to move your NPCs in the dynamic naviga on mesh Figure 104: Naviga on Mesh Triangle Providers 88 An fully working example of this with AI is provided in the SurvivalShooter demo game bundled with Dungeon Architect Figure 105: Sample NPCs with Naviga on Agent behaviors The nav mesh agent requies a CharacterController script to be present in the game object var agent = GetComponent(); // Move the agent to the target position agent.Destination = targetPosition; var velocity = agent.Velocity; // Agents velocity var direction = agent.Direction; // Agents movement direction var distanceToDestination = agent.GetRemainingDistance(); // Stop moving the agent agent.Stop(); // Resume movement agent.Resume(); 89 Figure 106: Sample NPCs with Naviga on Agent behaviors 90 Have a look at the shooter game demo in the samples folder for a complete example Figure 107: Shooter Game Demo in the Samples folder 14 2D Support Dungeon Architect fully supports 2D. You can use the same workflow to create beau ful 2D levels. A sample 2D game comes along with Dungeon Architect to help you get started. It demos dynamic 2D procedural level genera on, dynamic 2D naviga on mesh genera on, 2D AI with patrol, seek and search behaviours 2D dynamic naviga on mesh genera on is also support. 91 Figure 108: Shooter Game Demo Figure 109: Shooter Game Demo 92 Figure 110: Shooter Game Demo Figure 111: 2D Demo game 93 Figure 112: Theme with 2D Sprites 15 Dungeon Builders The Default dungeon builder used to create the layout is swappable and you can provide your own implementa on This is useful if you want to use your own algorithm for genera ng the layout of your dungeons. You are not limited to a grid based system. 15.1 Crea ng a new Builder To create a new builder, subclass DungeonBuilder under the DungeonArchitect namespace and implement the virtual methods using using using using UnityEngine; System.Collections; System.Collections.Generic; System.Linq; 94 Figure 113: 2D Demo game Figure 114: The Dungeon Builder can be swapped with your own implementa on 95 using System.Text; using DungeonArchitect.Utils; [ExecuteInEditMode] public class MyDungeonBuilder : DungeonBuilder { public override void BuildDungeon(DungeonConfig config, DungeonModel model) { base.BuildDungeon(config, model); // Add your builder logic here } public override void EmitMarkers() { base.EmitMarkers(); // Emit markers here by calling EmitMarker() } } Have a look at GridDungeonBuilder under Assets/DungeonArchitect/Scripts/Builders/GridDungeonB for reference 15.2 Using a different Builder If you’ve created a builder and would like to use it with your dungeon actor, drop in an exis ng dungeon actor, remove the exis ng builder script and replace it with your own 15.3 Example Builders Dungeon Architect comes with a sample builder named SimpleCity. It could be used as a good reference for building your own builders There are also examples on how this sample builder can be further extended by the users using Marker Emi ers script. It is used emit markers around the boundary of the city, so theme files can decorate them as strongholds 96 Figure 115: Dungeon builder script a ached to the Dungeon game object 97 Figure 116: Builder Code Loca on Figure 117: Builder Samples Loca on 98 Figure 118: Sample City Builder Figure 119: Sample City Builder 99 Figure 120: Stronghold Wall Emi er Figure 121: Stronghold Wall Emi er 100
Source Exif Data:
File Type : PDF File Type Extension : pdf MIME Type : application/pdf PDF Version : 1.5 Linearized : No Page Mode : UseOutlines Page Count : 100 Creator : LaTeX with hyperref package Title : Dungeon Architect User Guide Author : for Unity 5 Producer : XeTeX 0.99996 Create Date : 2016:11:10 13:49:53+05:30EXIF Metadata provided by EXIF.tools