📜 ⬆️ ⬇️

Unity3d Getting started, practical advice. Review

Good day. This article focuses on the Unity3d multiplatform tool. The article discusses the best, in my opinion, ways of working with the engine, gives practical advice on operation and additional (general) information; considered the prospects for the development of Unity3d.

Content:




Section 1. Introduction


What is Unity3d?

Unity3d is a modern cross-platform engine for creating games and applications developed by Unity Technologies. With this engine you can develop not only applications for computers, but also for mobile devices (for example, based on Android), game consoles and other devices.
Let's talk a little about the characteristics of the engine. First, it is worth noting that the game engine is integrated into the Unity development environment, in other words, you can test your game without leaving the editor. Secondly, Unity supports the import of a huge number of different formats, which allows the game developer to construct the models themselves in a more convenient application, and to use Unity for its intended purpose - product development. Thirdly, scripts (scripts) are written in the most popular programming languages ​​- C # and JavaScript [1].
Thus, Unity3d is a current platform with which you can create your own applications and export them to various devices, be it a mobile phone or a Nintendo Wii console.
In order to create your game, you at least need to own one of the available (on Unity) programming languages: C #, JavaScript or Boo.
')
image

It will be great if you own, for example, 3Ds max, it will help you a lot when creating a game. As for me, I had to master 3Ds max at a basic level, because I could not find the model of a house I needed anywhere [3]. In any case, you will need 3Ds max installed on your computer if you are going to import ready-made 3D models. For, for the most part, the necessary models have the format of a project, i.e. it will be necessary to transfer them to the appropriate format for Unity3d, for example, in * .3DS, and only after that do the import into Unity, otherwise the latter will generate an error.

Section 2. Getting Started


Auxiliary literature

Referring to the literature that will help us study Unity3d, namely, to Unity 3.x Game Development Essentials [2]. The book in the public domain can be found in Google, if you prefer free content.
What is this book about? Perhaps about everything that is needed to create a full-fledged game. I strongly recommend to purchase this book and study it yourself.
A few words about the game and the content of the book. Your player is on a desert island, he needs to be saved, for this he performs various tasks and, hopefully, he is saved. The game can be completed in a couple of minutes, but creating a game takes far not a couple of minutes, not even a couple of hours, perhaps.
The book contains a very detailed guide to creating a game from scratch. It describes a lot of things that you will most likely need to create your game.

image

The book is written in English; Those who do not know English, it will not be difficult to intuitively guess what is at stake, for the book is written without any special intricacies.

image

image

It is worth paying attention to

NB!

I will give some tips when creating a game in Unity3d.

Âş Colliders
What is it - a collider? A collider is an area of ​​space, interacting with which certain scripts and actions are executed. To better understand what it is, imagine that you are approaching the automatically opening doors of a department store. A couple of meters from the door, the sensor is triggered and the doors swing open in front of you, but if you walk for three meters, nothing will happen. Just that zone in which the motion sensor operates, which is responsible for opening the doors, is the collider. You enter the zone - the doors open, exit the zone - and the sensor will no longer react to your presence. Similarly in the game.
So, about the colliders. Suppose we imported a car to our project and want to generate a collider for it. You can automatically generate a collider for the entire car, but then for every detail of the car — lights, seals, mirrors, tires — a collider will be generated.

image

This is absolutely not optimal. Of course, we do not need to generate such a large number of colliders, it suffices to restrict one!

image

Please note that this is not a subtlety. Trying to save memory is needed everywhere. Do you have any place in the game where the player can not get? Do not generate any colliders for this place at all. Do you have a door that you imported into a project from 3Ds max? Probably, it is very well traced (he himself faced with the fact that at the door even the screws were traced by a separate object), it means that create one box collider for the entire door - you will save a lot of memory! Believe that this saved memory is still very, very useful for you.

Âş Optimum work with scenes
Let's talk about scene optimization, the scenes themselves will be discussed further.
Imagine the following situation: we have a “home” scene - when a player is in a building and a “street” scene - when a player leaves the building to the street. Naturally, from the second scene we can see the house, i.e. part of the first scene, and vice versa (if, of course, the building has windows). In this case, the following next scene construction is optimal. In the first scene, everything that relates to the street (that is, the place where we cannot reach without moving to another scene) should be as simple as possible. In other words, we need to leave only the appearance of the view from the window, and gut all the stuffing. Those. all colliders delete, resolution, etc. minimize. Indeed, why should the processor be strained with processing the area we cannot visit? Similarly, we act with the second scene ("street"). In this case, we can generally remove everything from home and leave only its “box”.
Do you want to create a minimap? Please just get rid of all colliders and lower the resolution, in this case your game will be optimal.
In this way, working with scenes becomes optimal. Once again, I note that these are not subtleties, they are serious things that require the attention of the creator.

Scenes

The finished game is a set of scenes interconnected (just like life is a set of days). We will talk about the optimal design of the game now.
Before you create your project - think about what it should include (what scenes). Make a list of scenes (on a piece of paper), consider what each scene will contain. Now try to split each scene into sub-prices, the more there will be, the easier it will be for your CPU. Of course, do not overdo it with the number of scenes. Suppose your player is in a building and never leaves, there are, for example, a couple of floors in the building, a roof, and there are three rooms on each floor. In this case, in my opinion, it would be optimal to “split” the building into two stages - two floors and a roof. Crushing each floor into scenes with rooms is not optimal. This is simply not necessary if each of the rooms is lightly loaded. In other words, it is necessary to properly use the processor's memory, but you also should not forget about getting pleasure from the game.

Debugging

Remember that a good creator must take into account that his game or application will be used on different computers, which means that you need to debug your content so that it can be used on different devices. The most obvious and important point in debugging is optimizing the application for various screen resolutions. This is an important point and the creator of the game must pay attention to him, otherwise, he alone can be satisfied with the result of his work.

Structuring

When constructing a game, it is important to keep in mind the structuring of data - an important aspect. It means that everything should be in its place. Create scripts? - create a folder for the scripts, and store them there, with a high probability, you will have more than one script, throwing them all over the project is not good, then you will suffer. From my own experience, I can say that you definitely need to create folders with scripts, sound files, GUI textures, materials, animations, perhaps prefabs and your own models (it’s better to store objects imported from 3Ds max in the last folder, in order not to scatter all the models on the project in a chaotic manner). When you create a script, remember that the name of variables, classes, etc. must speak for themselves. If you want to create a script for inventory (pick up an item, use an item), then it is better to start all the scripts of repetitive actions (for example, lifting) with a keyword, for example: Catch <item name>; Use <item name>, in which case it will be easier for you to navigate the project, and it looks so much nicer.

image

Section 3. Practical Tips


Remember the golden rule: a good program is not the one that is written out and debugged to the limit, a good program is one that is written right away and requires minimal “costs” to debug. If you use this rule, then everything will be much better for you than for those who do not use this rule.

Scripting

Alas, this subsection will be quite short. Just try to first present what you want to implement, then try to describe the algorithm with words, and then transform the words into working code. Using the book, which was discussed above, you hardly have to sweat a lot over the development of codes and other things, I repeat that the book describes almost everything that may be needed, and everything that is not described can be easily thought out.

Video lessons

I recommend the following youtube channels for review:
  1. www.youtube.com/user/4GameFree
  2. www.youtube.com/user/FlightDreamStudio
  3. www.youtube.com/user/3DBuzz


Fortunately, the Unity software product is constantly updated, but, alas, the video tutorials themselves cannot do this. It turns out that a huge number of videos, relevant a year ago, are losing their relevance and become, simply, useless.
1 - here you will always find relevant video tutorials, a clear explanation, a detailed analysis of scripts and all actions. I have not found anything better than this channel yet. If you do not have any idea at all about creating a game, then you definitely need to look at this channel. 2 - a serious team, video lessons only, a pity, less than that of 1. 3 - there are useful things, it is a pity that the video lessons have become almost irrelevant.

Troubleshooting

Unity3d is such an engine that if you have errors in writing scripts, then your game will not start. If there are no obvious errors, then the game starts, if something goes wrong, then the console will tell you about it.
These are warnings, they just tell you about possible shortcomings, flaws:

image

These are errors, if any, the game will not start:

image

image

Section 4. Completion


findings

Unity3d is a very flexible engine that provides greater freedom of action for the user. To simplify the life of the developer and the consumer, you can take some steps to optimize your project.
Now we, with our knowledge base, can safely start creating our ultra-popular application!

Game publication

You can publish your finished game on one of the game services, for example, on www.kongregate.com

*Optimization

If you are reading this section, then either you are just wondering what is written here, or you have not read the NB! from section 2. Let's hope that you belong to the first category. In this subsection, once again I would like to note that you need to immediately write the optimal game, and not to write it at least somehow, and only then to debug - this is a disastrous way and you should not do that. For optimization, refer again to the second section.

Section 5. Additional Information


Graphic Theory

Practicing without a theory is not very interesting, so I advise you to get acquainted with the theory of computer graphics. www.intuit.ru/department/graphics/graphalg/lit.html
You can test your theoretical knowledge here www.intuit.ru/department/graphics/graphalg

useful links

  1. www.4game-free.com - site of the guys who make great video tutorials
  2. www.youtube.com/watch?v=9Af617SEQZQ&list=SPEF925EF9F86651DD&index=1&feature=plpp_video - he didn’t really understand the channel, but it seemed to be very useful
  3. www.hongkiat.com/blog/60-excellent-free-3d-model-websites - here you can find links to 3D models
  4. www.youtube.com/user/AlexShebanov/videos?flow=grid&view=0 - work with 3Ds max
  5. www.youtube.com/user/khproton/videos?flow=grid&view=0 - I learned the basics of 3Ds max with this channel, I recommend it for review
  6. www.youtube.com/user/Aevideoss/videos?flow=grid&view=0 - you can find useful videos about 3Ds max


Opinion

Unity3d is really a powerful engine [4], with which you can create real, working games. However, like any software product, it has, in my opinion, its flaws.

Âş 2D graphics
I believe that this is the main failure of Unity. The complete absence of normal, adequate work with 2D graphics. It means the creation of 2D games. You can create such a game, but you will have to strain and pervert. If Unity developers can refine this flaw, then it will be very, very good.

Âş Prefabs
I would like to see more prefabs, some ready-made things, objects, for example, houses, objects of elementary interior - tables, chairs. Yes, all this is in the Unity store [5], but, alas, many things are paid for there, and free products are only occasionally worthy of attention. A separate talk about the 3rd person controller - I'm sorry, but this is simply unacceptable:

image

Âş Image Optimization
I would like to work with image optimization for different screen resolutions was easier. After all, it is enough to work a little with coordinate transformation and then you will not have to think about how to calculate dimensions, coordinates through the size (resolution) of the screen.

Information sources



[1] habrahabr.ru/post/137926
[2] unitybook.net
[3] Link to video tutorials on 3Ds max, refer to the section "Useful links"
[4] Unity Wiki
[5] unity3d.com/asset-store

Inspirer, teacher and mentor
- D. Grigoriev, Associate Professor, Department of Computer Science, St. Petersburg State University Mathematical and Mechanical Faculty.
As for me, I am studying at the second year of MAT-FUR, I am studying on the subject of Computer Graphics (we study the theory of graphics and game design on the Unity3d platform).

Source: https://habr.com/ru/post/161463/


All Articles