Updated information about this project

This article belongs to a series that consist on making a first person game about finding objects inside a maze. It’s one of my very first series from the channel. Now I reworked this project and you can download it to import in your own Unity project. Some day I will make a new series about this project, subscribe to my channel to see all the fresh content about Blender, Unity and programming.

Follow me on itch.io and download the source code of this project



YOU CAN TRY THIS GAME HERE, IT MAY TAKE A LITTLE WHILE TO LOAD
🔻

MOVEMENT: WASD CAMERA LOOK: MOUSE



Introduction of the old article

This is the beginning of the Labyrinth series, in which we’ll create a simple prototype of a first-person game in which the stage will be a labyrinth, while we see all the tools that Unity has to create games.

This series is ideal for those who do not have experience with Unity as it shows a little of everything and without going into detail, the purpose is rather to observe the entire development process to get a general idea.

Go to the project’s Main Page

Video related to this article

Before we begin, I invite you to watch this video from the My First Game series at Unity.




Creation of the project

When you run Unity or Unity HUB, a window appears in which you can create new projects, open them and access the tutorials.

We will create a new 3D project, give it a name and choose a location on the disk. Everything else is optional. When everything is ready we create the project

We give it a name and select the 3D template.

Fig. 1: Unity startup window. Create or load a project.

The first thing we’re going to do is create a new scene. In this version of Unity, by default we create the scene “SampleScene.unity”, as seen in the header of the program in Figure 2.

To create a new scene click on File > Save Scene As…

Fig. 2: To save a new scene go to File > Save Scene As…

We give it a name and keep it. When you do it, you can see in the header the name of the new scene.

Fig. 3 Pop-up window to save the scene.

Each scene has its own design independent of the others. For example we can use one scene for the main menu and another for the game.

It’s all going to depend on how we want to structure the game.

Creating folders

It’s important to set up an organization system for our Unity game files from the beginning, because as we go along we’re creating more Scripts, importing more files and things get cluttered easily.

All project files are located in the “Project” window, inside a folder called “Assets”. This folder can be found in the directory we defined for the project.

Fig. 4: Create a new folder for the project.

As can be seen in figure 4, right-clicking displays a menu with different options, go to the “Create” option and choose “Folder”.

We create as many folders as necessary to organize ourselves, this part is personal.

Import Packages

To start making a game in Unity is not necessary to create everything from scratch, we can use existing libraries to start working on an idea. Next we’ll import Unity Packages from the Standard Assets library and the Asset Store.

Standard Assets – Unity

In the version of Unity that I had at the time of recording the video, you could import the Standard Assets packages, a library offered by Unity that has different prefabrications, effects and scripts that are useful to start with.

Right-clicking on the folder we have the option “Import Package” where we can choose a package that we have downloaded using the option “Custom Package” or we can choose a package from Standard Assets.

If you do not see all the packages as shown in Figure 5, you have the option to download them from the Asset Store, but you must have a Unity account to do so. We’ll talk about that later.

Fig. 5: Import packages from the Standard Assets library.

In this case I will import from Standard Assets the packages “Characters”, “ParticleSystems” and “Utility”.

With the package “Characters” we will be able to place in the stage a prefabricated one that has implemented a control in first person.

ParticleSystems brings some interesting effects to use, such as fire and smoke.

Utility brings some useful scripts like a frames per second (fps) counter.

Asset Store – Unity

Unity’s store contains an infinity of Assets, some of them paid and others free.

To access the shop we use the Unity Asset Store tab, if it is not open, go to Windows > Asset Store or use the direct access Ctrl+9. As shown in figure 6.

Fig. 6: Open the Assets shop from the Window.

To use the store we must log into our account (we can do it from Unity). Then using the home screen or the search bar we can explore the content.

In order to see how Asset Store is used we are going to download two packages. The first is called “SkyBox” and the second “FastMobileBloom”, we use the search bar to find them, in figures 7 and 8 you can see the miniatures of the packages.

Fig. 7: Skybox package from the assets store.

Fig. 8: FastMobileBloom package from the assets store.

To add them to our project we enter the package and put “Download”, at the end of the download we have the option “Import”.

Fig. 9: When entering a package we can download and import it, read comments and more.

Project hierarchy

Within each scene all the elements of the game will be defined, that is to say a scenario, objects that are part of the world, invisible objects that serve for the logic of the game, graphical interface, etc. All these elements are known as GameObjects and will be listed in the hierarchy of our project.

As you can see in figure 10, when creating a new scene, we have two GameObjects that come by default. A camera and a directional light.

Fig. 10: Project hierarchy. By default we have a camera and a directional light.

Let’s delete the camera and start adding objects to the scenario.

By right clicking on the hierarchy we have the option to add different GameObjects, e.g. empty objects, primitives, lights, etc.

Fig. 11: Right-click on the hierarchy to create new objects.

I’m going to set up a simple stage with a floor plan and some buckets and cylinders.

Fig. 12: Plan created from the hierarchy.

As we add more objects to the scenario the hierarchy grows. It’s also recommended to have a good organization from the beginning, placing appropriate names and using Empty GameObjects to group the objects.

Fig. 13: Adding objects to the world.

Note figures 14 and 15. In the first one you can see that both cylinders are contained by the cube, as they are slightly to the right and the cube has an arrow to unfold and collapse the contents. In figure 15, on the other hand, it is observed that they are at the same level, so to speak.

Fig. 14: The cube is the father of the cylinders.

Fig. 15: The hub and cylinders are on the same hierarchical level.

This represents the kinship that exists between GameObjects. In figure 14 it is said that the cube is the father GameObject and both cylinders are children. This implies that the cylinders are going to be affected by certain changes that apply to the parent. For example if we deactivate the cube, both cylinders will also be deactivated.

The same applies to the transformation component, for example. The position of the cylinders is measured with respect to their parent, so if we move the parent, the cylinders move together.

Materials

To apply colors and textures on the objects of the world the materials are used. Let’s create some to see how they work. Right click on a project folder then Create > Material, as shown in figure 16.

Fig. 16: Materials creation process.

The material is visualized as a sphere in which are applied the properties of the material we must assign it a name, as always maintain the order from the first moment benefits us in the long term.

Fig. 17: Display of the materials in the project window.

The materials have several parameters that define it, in our case we will simply modify the color by clicking on the box to the right of “Albedo”. When doing so, a color palette appears where we can choose the color or write its hexadecimal code.

Fig. 18: Display of material properties in the inspector.

To apply a material we simply drag it over the desired object.

Fig. 19: A material has been applied to the plane.

Lighting

Let’s select the directional light from the hierarchy or in the scene window.

Fig. 20: Materials have been applied to all objects in the scene.

Directional light is a source of light such as the sun, i.e. situated in infinity and sending all its parallel rays. For this reason moving the source or making it larger does not affect the illumination of the scene, but changing the rotation if it does. We see it in the direction of the shadows.

Fig. 21: Rotation of the directional light, the shadows are projected in another direction if we compare with figure 20.

Create a ladder with primitives

Let’s do this little exercise to see the elements of Unity’s toolbar, particularly the tools that will allow us to modify the Transform component of GameObjects. We started by creating a cube in the hierarchy.

Fig. 22: Unity’s basic toolbar.

The tools move, rotate and scale are shown in figure 22 in positions 2, 3 and 4 respectively and are quickly accessed using the “W”, “E” and “R” keys (respectively).

If we press the R key with the cube selected, we can scale it using the “Gizmo” of the three axes, as shown in figure 23.

Fig. 23: Scaling a GameObject in one direction.

We scale it in two directions to give it the appearance of a step.


Fig. 24: Scaling a GameObject in one direction.

We apply a material to it and with the W key we can place the step on the stage.

Fig. 25: Positioning of the object in the scene.

We can easily duplicate the object using the shortcut CTRL+D and with the W key raise it a little and move it backwards.

Fig. 26: Duplication of a GameObject.

We can repeat this process with several selected steps.

Fig. 27: Duplication of a set of GameObjects.

Let’s create an Empty GameObject and call it “Scenario”.

Fig. 28: Creating an Empty GameObject to organize elements.

Fig. 29: The Empty GameObject is given the name Scenario.

Then we select all the objects and drag them to this new object to group them. In this way we can collapse the whole content and the hierarchy is more orderly, as shown in figure 30.

Fig. 30: All GameObjects on the stage are dragged into the Empty GameObject and the content collapses.

First-Person Controller

The reason why we previously removed the camera is because we are going to place the prefabricated “FPSController” from Standard Assets on the scene and it already has a built-in camera. This prefab is located in the directory Standard Assets > Characters > FirstPersonCharacter > Prefabs.

Fig. 31: Prefab FPSController of the Standard Assets Characters package.

We take it to the scene and put it where we like.

programa unity3d. se observa una escena con suelo marrón, una escalera azul, dos cilindros rojos y dos cilindros azules.
Fig. 32: The FPSController prefab is placed in the scene.

Bugs

We are already able to do some tests, in the top center we have three buttons.

The Play button is used to start running the game. The second button pauses the game but does not end it. The third button is used to advance a single frame in the game.

Pressing the Play button displays an error sign saying that all errors must be fixed before you can enter game mode.

Fig. 33: When trying to enter game mode an error message appears.

This is a problem that we are going to encounter very often, especially at the beginning and it is usually very frustrating, even more so if we are learning to program.

To get information about what is happening we have the “Console” window. If it is not open, you can find it in the “Window” menu.

Fig. 34: Several warnings with a yellow sign are displayed on the console.

In figure 34 we see a large number of warnings but this does not affect the operation of the game, are suggestions for optimizing the code, warnings for use of obsolete code and so on. If only we had warnings we could enter the game mode without problem.

Figure 35 is a screenshot after clicking the “Clear” button, this clears the warnings and lets you see the errors that cannot be overlooked in order to enter the game mode. These are shown with a Red sign.

Fig. 35: The console displays an error message with a red sign.

There is not much information about the error but it is enough for us to understand that there is a file that is not found. If we look at the address we see that it is related to the Standard Assets package and we see that its address begins with “Assets > Standard Assets > …”. In the video we made a folder called “External Packages” and inside it we put the Standard Assets package.

Everything seems to indicate that there is some process that is looking for Standard Assets files but inside the Assets folder, not the External Packages folder, so I move the Standard Assets folder to the Assets folder and the error is fixed. Now if we are able to enter the game mode.

Fig. 36: The Standard Assets package is taken to the Assets folder of the project.

Testing the game at Unity

The prefab FPS Controller works like a standard first-person game. Move forward, backward, sideways with WASD keys or arrows. Jump with space bar, with Shift you can run. With the mouse you can control the view and it has the sound of steps. It’s a good starting point to start forming an idea.

Fig. 37: After correcting the errors, the game mode can be entered.

Build the project

Now we will generate a standalone version of the project, ie a set of folders and executable file that can run on our operating system without having the Unity engine open.

Go to the File tab and click on Build Settings to configure the compilation parameters.

Fig. 38: To make a compilation click on File > Build Settings.

We get the window illustrated in figure 39, there we can select the target platform.

If you look at the top is where the game scenes are listed. At that time we don’t have any scenes added to the compilation.

Fig. 39: Window with compilation parameters. No scenes have been added.

By clicking on the Add Open Scenes button we are going to add the scene we were working on throughout the video. As you can see in figure 40.

Fig. 40: Compilation window. The scene in which we work has been added.

Now all that’s left is to click on Build And Run and choose the folder where to place the generated files. At the end of the compilation process the game runs and a window appears in which we can select the resolution and quality. Press the Play! button and the game starts.

Fig. 41: Game start window. You can choose the resolution and quality.

Conclusion

In this article we saw the first steps in starting a game at Unity. We put emphasis on organization, which will benefit us in the long run in development.

We saw the scenes of Unity, each scene is a world apart and contains a certain amount of elements or GameObjects that are listed in the hierarchy of the project.

We import files from both the Standard Assets library and the Asset Store. At the beginning the most important thing is to try to give form to the ideas that we have, for this the assets of the bookstores facilitate the things to us.

We saw something about the parentship that exists between GameObjects and how changes applied to a parent object also impact their child objects.

We create materials that give color and texture to objects.

The directional light source serves us to illuminate a scene as the sun would, the shadows will be projected according to the rotation that this light source has.

We made a simple ladder using the primitives that can be created with Unity and applying transformations to them, that is to say changes of scale, rotation and position.

We place the Standard Assets prefabricated “FPSController” which is a first person control. Quickly we already have a character that can go around the stage, run and jump.

In the process there were bugs that we had to fix in order to get into game mode. Debugging errors is a difficult task when we start programming, but with practice we make fewer mistakes and it’s easier to correct them.

Finally we made an executable compilation from the operating system. There are a lot of platforms to which we can export our game in Unity. In principle we are going to export to Windows and Android.

Introduction

This time I wanted to share a little experiment I did using Blender, Unity and Arduino. The simulation of an industrial process using 3D models made in Blender and making a scene in Unity.

Here in the Alto Valle of Patagonia fruit growing is practiced and as I work doing industrial automation I have the opportunity to observe how the packing sheds work and the treatment of the fruit.

The industrial process I try to simulate is a fruit grinding line. The fruit arrives through a water circuit to a fruit elevator that lifts the fruit to a sorting table, where people manually discard the bad fruit. Then the fruit continues its ascent to a mill where it’s transformed into pulp and deposited in a tank. This is where the simulation comes in.

Motivation

The idea of this experiment combining Unity and Arduino arose because I needed an idea for the final work of a subject of my career. The subject is PLC (programmable logic controllers).

I wanted to take advantage of everything I’ve learned from programming and 3D design, designing a computer simulation to test the programs we load into the PLC.

Description of the experiment

The idea is to use an Arduino Mega board to control the simulation in Unity. This is done using RS-232 communication. The Arduino board is inside a 3D printed box with a pair of Switches on the lid.

With the Arduino Mega you read the status of the switches and with this information you can create a word that is then sent via RS-232. The physical connection is made with the Arduino’s USB port.

In Unity the messages of the COM port are read.

The video shows that there are synchronization problems. This is because the COM port reading is done in the Update method of a class that inherits MonoBehaviour. An alternative to this is to use a different Thread to do the reading.

Conclusion

We haven’t decided yet what we’re going to do for the final work, however, this idea of an Arduino-Unity hybrid project is very interesting to me and I’ll probably make a series of videos for the channel. I think it might be fun.

Introduction

Creating the 3D model of a face can be a challenging task, especially when we’re just getting started in the 3D world. In this article we will see an easy and practical way to make a 3D face with a well-achieved geometry in Blender, but the technique can be applied in any 3d design software.

Timelapse of the modeling process of a 3D face

In the following video I use this process to make the 3D model of a Venetian mask. The textures were made using Substance Painter.


Topology

Topology is the discipline that studies objects and their geometric properties. In 3D models it refers to the set of vertices, edges and faces and their interrelation.

It’s very important that our 3D models have a good topology, that way the modifiers, proportional deformation, texture painting and other functions will have better results.

We achieve this by using 4 vertex faces (quads) and creating edge loops that fit the natural curves of the object we want to model. In the figure 1 we see those faces and how they are distributed in the 3d model.

Fig. 1: Reference image for 3d face topology.
Source: Blender Artist.

If we use this kind of images as reference for our modeling procces we will achieve a 3D model of a face with a correct topology.

Reuse of the 3D model for a character

Marittie is a chibi character I made from a drawing my girlfriend made some time ago.

Fig. 2: Reference image for the Marittie 3D model.

At the time, I had a year’s experience with Blender and was not yet familiar with the concept of topology. However, I managed to make a model and at that time I liked it very much.

Fig. 3: Render of Marittie’s old model.

The topology of course was not good. The model had a very high number of polygons, triangles, quads and n-gons, very badly optimized.

The animation was of course difficult to achieve. There were irregularities that were difficult to correct.


Fig. 4: Another render of the old model.

As time went by I learned to improve the geometry and it was time to remake the 3D model.

I had made the 3D model of the Venetian mask, so I thought why not use this 3D model as a starting point for my character design?

I made a copy of the mask and started applying proportional deformations. As the topology of the face was good, it was easy to transform the Venetian mask into Marittie’s new face.

Fig. 5: Render of the new model.
Fig. 6: Another render of the new model.

Fig. 7: Comparison of the old model and the new model.

Conclusion

It is important to achieve a good topology in our 3D models, because that means we can apply transformations to that mesh and it will respond appropriately.

The improved topology of the new model makes animation easier. The proportional deformation tool has better results and also the seam marking and UV unwrapping will be easier.

I wanted to share a project I did long before I started programming and the world of video games. It’s a computer cabinet made in mdf.

History

I had been making things in mdf, such as sets of chess and boxes that my girlfriend had decorated with decoupage, I liked quite and had ease. One day I was in chemistry class in the university and I showed a friend the little jobs I had done. He was interested and told me that he needed a temporary wooden box to cover his computer because he had not yet got a cabinet and his computer covered it with a cardboard box.

Figure 1 shows a structure for the motherboard and power supply that he made.

Fig 1: Supporting structure.
Fig 2: Initial disposition of the elements. Below power supply and hard disk.

So the idea was to make a box containing that to prevent it from getting dusty.

Design of the MDF PC case

My friend made a design that seemed convenient for ventilation and from that I made a 3D design using SolidWorks (at that time I didn’t know Blender), that was my first approach with 3D modeling without counting that when I was a kid I made maps for Counter Strike using 3D Entity.

With the 3D design we were able to make some renders and adjust it until it became as my friend wanted. From that 3D design I made a plan of 6 views for the cuts of the pieces (I believe that by that time I had also made technical drawing in the university).

Fig 3: Part of mdf and plane of the cuts.

Taking as base the plans, I drew the six pieces on a plate of mdf of 5 mm of thickness, in this part the measures were taken well so that everything is to square.

Fig 4: With all the cuts drawn, holes are made so that the sheet of the jigsaw can enter.

I made all the holes in the internal cuts so that the sheet of the jigsaw enters.

Fig 5: Cut from one side.

I made the simple cuts using a hand jigsaw and the precise cuts with a bench jigsaw.

Fig 6: Inside cut of a side piece of the mdf cabinet.

The cuts were made to measure, only not so straight because they were made by hand.

Fig 7: The first piece of the mdf cabinet, one of the sides.

Figure 8 shows that the structure was already taking shape.

Fig 8: Cabinet parts cut without gluing.

I glued the three pieces using glue and then applied a press so that the structure is very firm, then the pressing tools are observed.

Fig 9: Gluing and pressing of the mdf cabinet.

Notice how the red metal press (a press itself) is in charge of keeping Monopoly’s box armed, so the structure didn’t collapse under its own weight.

Fig 10: Design for disk bays.

For the disk bays we made a three-storey structure, in the following figure the idea for the design is shown.

Fig 11: Unpainted disc bays.

The piece was also built with 5 mm mdf and a layer of red acrylic paint.

Fig 12: Disc bays finished.

Then we started to think about the decoration of the box, because it had to have even a coat of paint. At that time I didn’t know as much about computer components and brands as I do now, however I proposed some designs that he liked.

Fig 13: Scribbling some designs while doing my German homework.

Fig 14: The mdf cabinet after gluing and with part of the design. The blue pieces are transparent acrylic.

The Republic of Gamers logo for an MSI board, I know.

Fig 15: Side of mdf cabinet, notice the acrylic placed in a groove at the top.

We had bought some meat pies to eat and it was getting late.

Here you can see that I’m putting the finishing touches. Our mdf cabinet was almost finished.

Fig 16: Retouches in the decoration of the cabinet mdf.

Fig 17: Cabinet mdf with screwed coolers.

We screwed the coolers in place, placed the structure with the motherboard, the fountain, the disks inside and finally the two pieces of acrylic that went into grooves. This was the final result

Fig 18: Final finish of mdf cabinet.

Conclusion

We managed to finish the mdf cabinet and my friend had a small box to house his computer. It was temporary until he finally got a PC cabinet.

In my opinion the dimensions were quite exaggerated, but my friend was worried (and rightly so) about refrigeration. In a metal cabinet the heat is partly dissipated by the thermal conductivity. In addition it provides protection to the circuits against electromagnetic noise.

However, if we take into account the fact that I used to cover the computer with a cardboard box, the mdf cabinet was a small improvement.

Exit mobile version
Secured By miniOrange