#8 Create Mountains with Unity. Build the Labyrinth

IMPORTANT UPDATE

I WILL PUBLISH THE FILES OF THIS PROJECT WHEN THE CHANNEL REACHES 1000 SUBSCRIBERS

…

I LEAVE AN UPDATED BUILD FOR YOU TO TRY, IT MAY TAKE A LITTLE WHILE TO LOAD
ūüĒĽ

MOVEMENT: WASD CAMERA LOOK: MOUSE

FROM HERE THE ORIGINAL ARTICLE CONTINUES

Introduction

In this arti­cle we are going to see how to cre­ate a ter­rain in Uni­ty using its own tools and we are going to cre­ate a labyrinth using the pre­fabs that were con­fig­ured in the sec­ond arti­cle of the project, click here to down­load the files and to see how to con­fig­ure the pre­fabs.

Go to the project's Main Page

Before we begin, I invite you to watch the fol¬≠low¬≠ing video.

CHECK OUT THIS CRAZY EXPERIMENT

Description of the objective

Create the labyrinth

To cre­ate a mod­el of the labyrinth we are going to use the pre­fab­ri­cat­ed ones that we cre­at­ed pre­vi­ous­ly, we will place them in the hier­ar­chy and we will begin to dupli­cate them and to arrange them in the space, as it is observed in the fol­low­ing figure.

escena en unity 3d, generacion de laberinto utilizando prefabricados
Fig. 1: Set¬≠ting up the stage using the pre¬≠fab¬≠ri¬≠cat¬≠ed ele¬≠ments shown in video 2.

Create terrain in Unity

To cre­ate a ter­rain in Uni­ty we will use the GameOb­ject "Ter­rain", which will allow us to mod­i­fy its relief and tex­tures in a sim­ple way using dif­fer­ent brush­es and parameters.

escena en unity 3d en la que se observa como crear un terreno en unity
Fig. 2: Using Uni­ty tools we can sculpt relief in the terrain.

Download Files

First we down¬≠load the next Zip file, extract the fold¬≠ers and take them to Unity.

Video 8 ‚ÄĒ Textures
carpetas de texturas que vienen en el archivo de descarga, unity 3d
Fig. 3: Extract the tex­tures from the down­load file to add them to the project.

mapas de las texturas que vienen en el archivo de descarga, texturas para unity 3d
Fig. 4: Each tex¬≠ture comes with its Albe¬≠do, Metal¬≠lic and Nor¬≠mal maps.


The next thing we do is remove all the ele­ments belong­ing to the scenario.

escena simple en unity 3d, suelo con textura cesped
Fig. 5: We start by com¬≠plete¬≠ly clean¬≠ing the stage.

Terrain Component ‚ÄĒ Unity

As men­tioned above we will use the Ter­rain com­po­nent to cre­ate a moun­tain­ous relief for the terrain.

This com¬≠po¬≠nent uses "Height Maps" or height maps to cre¬≠ate reliefs, these maps are grayscale tex¬≠tures in which com¬≠plete¬≠ly black areas are mapped with min¬≠i¬≠mum height and white areas with max¬≠i¬≠mum height (both heights con¬≠fig¬≠ured in the para¬≠me¬≠ters), the rest of the gray areas will have a height pro¬≠por¬≠tion¬≠al to its col¬≠or tone.

We can see this in the fol¬≠low¬≠ing image.

mapa de altura o height maps para general relieve en 3d y crear terreno en unity 3d
Fig. 6: The ter­rain works with Height maps.

In the hier­ar­chy right click > 3D Object > Terrain.

jerarquia en unity 3d, crear terreno en unity
Fig. 7: From the hier­ar­chy we cre­ate a GameOb­ject type terrain.

In the stage a white plane appears and in the inspec­tor we can see that it has two com­po­nents that define it, the com­po­nent Ter­rain and a Col­lid­er type Terrain.

parametros del componente terreno en el inspector de unity 3d
Fig. 8: The ter­rain appears in the sce­nario and we can see its prop­er­ties in the inspector.

Terrain Component Setup

It is impor¬≠tant that we first con¬≠fig¬≠ure the basic para¬≠me¬≠ters of the ter¬≠rain, such as the dimen¬≠sion and the dif¬≠fer¬≠ence that will exist between the max¬≠i¬≠mum and min¬≠i¬≠mum height. Then we can mod¬≠i¬≠fy these para¬≠me¬≠ters but we will prob¬≠a¬≠bly lose the design we had.

As shown in fig­ure 9, click on the gear icon to go to the con­fig­u­ra­tion. Then enter the parameters.

The only thing I'm going to change is the res¬≠o¬≠lu¬≠tion of the land, which will be 1000 x 1000.

boton configuracion del gameobject terreno, crear terreno en unity 3d
Fig. 9: First con­fig­ure the basic para­me­ters of the inspector.

parametros del componente terreno en el inspector de unity 3d
Fig. 10: We adjust the res­o­lu­tion of the terrain.

Texture Setup

We can paint the ter¬≠rain using dif¬≠fer¬≠ent sets of tex¬≠tures that will con¬≠sist of Albe¬≠do and Nor¬≠mal maps. First we select all the nor¬≠mal maps we have, in the inspec¬≠tor we choose the type of tex¬≠ture as "Nor¬≠mal map" and apply the changes. We do this for all the nor¬≠mal maps we have.

mapas de las texturas que vienen en el archivo de descarga, texturas para unity 3d
Fig. 11: Select tex¬≠tures such as Nor¬≠mal Map or Nor¬≠mal Map.

seleccionar tipo de textura en unity 3d
Fig. 12: In the inspec¬≠tor we can select the type of tex¬≠ture. Select Nor¬≠mal Map and apply.

Then select the ter¬≠rain again and click on the brush icon, then on "Edit Tex¬≠tures‚Ķ", "Add Tex¬≠tures" (fig¬≠ures 13 and 14).

herramienta pincel en componente terreno unity 3d
Fig. 13: Select the brush tool on the ground component.

agregar texturas al terreno en unity3d
Fig. 14: We must con­fig­ure at least one paint­ing for the terrain.

In the pop-up win¬≠dow we can select a tex¬≠ture that rep¬≠re¬≠sents the Albe¬≠do in the RGB chan¬≠nels and its Alpha chan¬≠nel is mapped in the soft¬≠ness. Anoth¬≠er tex¬≠ture for the sur¬≠face Nor¬≠mals. We can also con¬≠fig¬≠ure the size of the mosa¬≠ic or Tile¬≠Size using the fields "Size" and "Off¬≠set" that are observed in fig¬≠ure 15.

ventana para seleccionar textura albedo y normal para pintar terreno en unity 3d
Fig. 15: In the pop-up win­dow we select an Albe­do tex­ture and a nor­mal texture.

Click on Select and choose first the Albe¬≠do map and then the nor¬≠mal map.

ventana para seleccionar textura albedo y normal para pintar terreno en unity 3d
Fig. 16: We must make sure to select the appro¬≠pri¬≠ate maps.

We'll do this for all the tex­tures we'll use to paint the terrain.

Fig­ure 17 shows some val­ues that work for TileSizes.

textura seamless para suelos, cesped con margaritas, cesped con hojas, tierra y roca
Fig. 17: Work­ing mosa­ic size values.

Once we set up all the tex¬≠tures, we should have them all avail¬≠able for use in the Tex¬≠tures in Inspec¬≠tor win¬≠dow, as shown in fig¬≠ure 18.

unity 3d componente terreno, texturas seleccionadas
Fig. 18: All the tex­tures of the down­load have been configured.


Making the labyrinth

First to keep things tidy I'm going to cre­ate an Emp­ty GameOb­ject that I call "Maze", inside which will be all the pre­fab­ri­cat­ed ones that I use to make the labyrinth.

jerarquia en unity 3d, empty object, lights, cameras
Fig. 19: We cre­ate an emp­ty object that will con­tain all the pieces of the labyrinth.

Then I drag all the pre­fabs to the stage and start dupli­cat­ing them and mov­ing them to form the corridors.

unity 3d dise√Īo de nivel, armado de laberinto utilizando prefabricados
Fig. 20: We start by plac¬≠ing all the pre¬≠fab¬≠ri¬≠cat¬≠ed parts on the stage.

To facil­i­tate the posi­tion­ing of the pieces we can use the ortho­graph­ic view. In fig­ure 20 at the top right we have what is called a "Giz­mo" that shows the axes X in red and Z in blue. By click­ing on these arrows we can change the view of the scene and if we click on the cube in the cen­ter we can alter­nate the view from Per­spec­tive to Orthographic.

In fig¬≠ures 20 and 21 we can see how this ortho¬≠graph¬≠ic view is. The effect it pro¬≠duces is as if all the ele¬≠ments were com¬≠pressed into one plane, so we do not observe the depth.

unity 3d dise√Īo de nivel, armado de laberinto utilizando prefabricados
Fig. 21: Dupli­cate the pieces and move them on stage to build the labyrinth.

unity 3d dise√Īo de nivel, armado de laberinto utilizando prefabricados
Fig. 22: Using the ortho­graph­ic view and bring­ing the cam­era clos­er we make sure that the pieces fit together.

We also put some doors on the stage. In video 4 of the series we cre­at­ed the pre­fab­ri­cat­ed door, here is the arti­cle.

unity 3d dise√Īo de nivel, armado de laberinto utilizando prefabricados
Fig. 23: We place sev­er­al doors in the labyrinth.

We go into game mode and go through the labyrinth to detect prob­lems. In fig­ure 5 you can see one of the bad­ly placed doors.

unity 3d dise√Īo de nivel, armado de laberinto utilizando prefabricados
Fig. 24: We test the scene for problems.

unity 3d puerta mal colocada
Fig. 25: Walk­ing through the labyrinth we found a door that was bad­ly positioned.

unity 3d puerta mal colocada
Fig. 26: We stopped the game mode to cor­rect the problem.

Relief modeling

Then we're going to start mod¬≠el¬≠ing the moun¬≠tains. Select the GameOb¬≠ject Ter¬≠rain from the hier¬≠ar¬≠chy and in the inspec¬≠tor click on the first icon of the com¬≠po¬≠nent (fig¬≠ure 27).

Then we select some pat¬≠tern in the sec¬≠tion "Brush¬≠es" that is observed in fig¬≠ure 28.

herramienta elevacion para crear terreno en unity 3d
Fig. 27: Select the Raise/Lower tool in the ter­rain component.

pinceles para aplicar la modificacion del terreno, crear terreno en unity 3d
Fig. 28: We choose a brush to apply the mod­i­fi­ca­tion to the terrain.

The next thing we do is paint in the edi­tor and the ter­rain will gain height.

modelado de terreno en unity 3d usando componente terrain
Fig. 29: We start paint­ing regions of the ter­rain to pro­duce ele­va­tions and cre­ate relief.

Anoth¬≠er use¬≠ful tool is the lev¬≠el¬≠ling tool (select¬≠ed in fig¬≠ure 30).

herramienta de nivelacion de terreno para crear terrenos en unity 3d
Fig. 30: Select the ground lev¬≠el¬≠ing tool.

altura de la deformacion que se aplica, crear terreno en unity 3d
Fig. 31: We choose the height val­ue at which we want to lev­el the terrain.

This will allow us to estab¬≠lish a cer¬≠tain height and as we pass it over the ter¬≠rain in the edi¬≠tor, the low¬≠er areas will begin to rise and the high¬≠er areas will descend, this is illus¬≠trat¬≠ed in fig¬≠ures 32 and 33.

crear terreno en unity 3d usando componente terrain
Fig. 32: The regions below the lev­el rise and those above descend.

modelado de terreno en unity 3d usando componente terrain
Fig. 33: We can estab­lish zones that will have a cer­tain height in all its extension.

relieve monta√Īoso observado desde el interior de un laberinto, juego en unity 3d
Fig. 34: We go into game mode to observe the moun­tain­ous relief from the per­spec­tive of the labyrinth.

relieve monta√Īoso observado desde el interior de un laberinto, juego en unity 3d
Fig. 35: The high¬≠est part of the relief is in the oppo¬≠site direc¬≠tion to the sun of the scene.

After play¬≠ing with the tools for a while, I end¬≠ed up with some¬≠thing sim¬≠i¬≠lar to fig¬≠ure 36.

The most impor­tant pur­pose of the relief is to cov­er the hori­zon and some­how pro­vide guid­ance to the player.

modelado de terreno en unity 3d, laberinto en el centro
Fig. 36: We use the above tools until we are sat­is­fied with the design.

Apply textures to the terrain

In the final phase of this arti¬≠cle on how to cre¬≠ate a ter¬≠rain in Uni¬≠ty we will apply the tex¬≠tures con¬≠fig¬≠ured above.

Select the brush tool in the inspec­tor, a pat­tern and a texture.

texturizar terreno en unity 3d
Fig. 37: Select the brush tool, choose the pat¬≠tern and tex¬≠ture to apply.

Then in the edi¬≠tor we go around the ter¬≠rain and paint.

We can alter­nate the tex­tures and with this we can avoid that the ground looks monot­o­nous with an only texture.

aplicar texturas a terreno en unity 3d
Fig. 38: To the base tex­ture we apply anoth­er tex­ture in dif­fer­ent places to break the pat­tern of repetition.

The moun­tains will have a base of earth and then we will be apply­ing in dif­fer­ent parts a rock texture

texturizar terreno hecho con herramientas de unity 3d
Fig. 39: We give moun­tains a base with the ground texture.
texturizar terreno hecho con herramientas de unity 3d
Fig. 41: We apply the rock tex­ture in dif­fer­ent parts of the relief.

texturizar terreno hecho con herramientas de unity 3d
Fig. 40: Ground tex­ture in the mountains.
texturizar terreno hecho con herramientas de unity 3d
Fig. 42: Rock tex­ture in the mountains.
escena en unity 3d, generacion de laberinto utilizando prefabricados
Fig. 43: Rock tex­ture in the mountains.

From time to time we go into game mode to see how the relief looks from inside the labyrinth.

relieve monta√Īoso observado desde el interior de un laberinto, juego en unity 3d
Fig. 44: We enter the game mode to observe the results.

escena en unity 3d, generacion de laberinto utilizando prefabricados
Fig. 45: Final design of the labyrinth.

relieve monta√Īoso observado desde el interior de un laberinto, juego en unity 3d
Fig. 46: Final design of the moun­tain­ous relief seen from the labyrinth.

Conclusion

We've seen how eas­i­ly we can cre­ate a piece of land in Uni­ty using the same tools that the engine pro­vides us. We also apply dif­fer­ent tex­tures to give it diversity.

The exer­cise pro­posed in this arti­cle and video is very sim­ple, but with enough time and prac­tice we can build a num­ber of reliefs.

This type of land has the lim¬≠i¬≠ta¬≠tion that cav¬≠erns or caves can¬≠not be built. For that we will have to super¬≠im¬≠pose anoth¬≠er 3D model.

In addi¬≠tion we have cre¬≠at¬≠ed the labyrinth using the pre¬≠fab¬≠ri¬≠cat¬≠ed ones con¬≠fig¬≠ured in pre¬≠vi¬≠ous entries. Sim¬≠ply by mak¬≠ing dupli¬≠cates and mov¬≠ing in space.

We can make both sim­ple and com­plex labyrinths and assem­ble a lev­el selec­tion sys­tem if we wish. The pos­si­bil­i­ties are unlimited.

Let's bear in mind that this project is only a pro¬≠to¬≠type, in order to achieve a bet¬≠ter graph¬≠ic qual¬≠i¬≠ty it is nec¬≠es¬≠sary to build bet¬≠ter 3D mod¬≠els and use a greater diver¬≠si¬≠ty of tex¬≠tures and high¬≠er qual¬≠i¬≠ty. It would be nice to add dec¬≠o¬≠ra¬≠tive ele¬≠ments such as rub¬≠ble or trees. 

YouTube
Scroll to Top
Secured By miniOrange