Creating Android applications. Start development under Android Creating a 3D game for Android Unity

  • 25.04.2021

Unity is the engine on which most of the modern games are built on different platforms. Through the engine, it is actually creating games focused on launching on computers (Windows, Linux, MacOS), mobile phones, tablet computers (Android, iOS) and even game consoles PlayStation, Xbox, Nintendo.

How to create games in unity?

The basis of Unity is a component-oriented concept. In fact, any game consists of the mass of objects diluted with additional components. For example, during the creation of the platformer, we create a GameObject, which additionally attach a graphic component to it, which is responsible for displaying the character, and the control component, it provides the character control by mouse, keyboard, joystick or touchscreen. The engine does not impose restrictions on the number of similar modules. You can add so many components to GameObject as needed. All work on the engine is built on the creation of GameObject and applying suitable components to them.

Newbies can mislead the visible simplicity of the process, although it is not. To create a unique and popular game will have to write a lot of components from scratch. More precisely, in the Unity environment it is called a script. The native language creation language is C #, but also partially used by JavaScript and Boo (Cropped Python Option). Create our own components is not easy, you can even say - this is a complex procedure directly tied to classical programming. Without the availability of a sufficient level of knowledge in programming, it will have to be unavassed.

Supported platforms

Many large projects prefer UNITY due to a huge list of platforms compatible with the engine. The finished application is really run on any computer operating system, popular mobile platforms and SmartTV. What to say, even browser games and applications for specific platforms ( like Tizen Os.) Preferably developed on UNITY.

However, here is not so smooth. If necessary, you can write specific algorithms based on low-level code, under the same Android you need to have thorough knowledge of Java.

The same is true of iOS. Another feature of the iOS is that under it is possible only from a computer or a tablet from Apple. In the absence of a MacBook or a similar device, the release of the game quickly stalls and Unity is not at all, Apple itself imposes a similar limitation. The output is simple: if there are iOS-development in the plans, you should choose a suitable device for assembly in advance.

How and where to develop a game on the engine?

The long-term game development process can be carried out both within Windows and Mac OS X. already exist versions of the editor under Linux, but it is not yet necessary to count on their stable work. Most of the time to create the game, the developer is conducted inside the Unity editor. You still have to write a lot of time to write code of scripts, we can create it either in standard monodevelop, or in any editor of a third-party developer. Now actively use Visual Studio, as well as Sublime Text, but only with due tuning.

Development of mobile applications is one of the most profitable classes in the computer industry. The creation of a game on Android costs several hundred or thousands of dollars, and profit can reach a million dollars. In this regard, many people are interested in developing applications for phone. In this article, you will learn how to create a game on android from scratch through a computer, which engine and the designer is better to choose.

No successful game costs without beautiful graphics, so creating a design is one of the most important stages of development. The design on the Android OS is implemented using the "Design Document" or Dzepock. You need to start creating a toy from his detailed study. The file contains:

  1. Object models;
  2. Functional specifications;
  3. Gaming content;
  4. Interface.

Consider each of the items in more detail.

Object models

This is information about the functionality of each subject. Object models are responsible for the possibility of buying and selling objects, as well as for improving the game characteristics of characters.

Functional specifications

Here is described by gameplay, the main features of each character. Also here is a description of the features of game items - weapons, aidheeks, armor and others. In fact, the functional specifications are the rules for which the gameplay occurs. The better this section will be worked, the easier it will create a high-quality android game.

Game Content

This is a text game filling. It describes the dialogs of characters and what the weapon can be damaged, how much health will take off, what characteristics will increase when using various equipment. It also contains a detailed description of each subject.

Interface

The interface is how the user will interact with the game. It includes the buttons with which you can manage the character, and the menu partitions: for example, play, account, settings, top players, help. If you do not have experience in creating applications for Android, before creating your own download from the Play Market and analyze the popular games and move the best solutions to your project.

Game engine

The basis of any game is the engine. This software that allows you to develop and run it. It contains a whole range of programs, including a rendering engine, a physical engine, sound, animation and much more. To facilitate the process of writing programs, third-party developers create their own game engines specifically for android applications.

Each of them offers various functions: Some are designed for 3D, others for 2D, multiplatform can be supported. There are a huge amount of such engines, but if you are new to, it is better to choose one of the most popular, as all the necessary functions will be present.

UDK.

Torque 2D / 3D

What is a game designer?

The designer is a program that combines the gaming engine and an integrated development environment. The designer makes the development process available to people who do not have programming skills. Some of the designers allow you to create games of certain genres, others have a maximum functionality, but cost much more money. For a beginner creator of mobile applications, the choice of the designer is one of the most responsible moments, because the fate of the future application will depend on its capabilities.

The designer allows you to create games of various genres for Windows, Android and iOS. It offers a large selection of finished locations, objects, characters and sound decorations, so the creation of the first android game does not take much time. Users familiar with JS and C ++ programming languages \u200b\u200bcan use the built-in GML. The only drawback is that the program is not translated into Russian.

Conclusion

Creating a game for Android is not quite simple, but a very profitable business. If you decide to develop a game and earn on it, first work the idea. Next, write "Design document" and decide on the game engine that can mostly reveal its potential. After that, you can proceed directly to the creation of the application in the constructor.

Video

To get acquainted in more detail with the process of creating android games, read the series of videos on this lesson.

How fast and relatively easy to create a simple game or an app for android? This is read about this in the article below, where work with the Unity3D engine is considered.

Do you play computer games? If so, then, in the process of passing the next game blockbuster, you sometimes had thoughts like: "But here, I would do wrong!". And you want to visit the role of the developer? Then, I suggest you a small but very entertaining "adventure";)

What is the engine and why is it needed?

Previously, during the days of the first computers, games and programs were created by the so-called "hardcore" method. That is, for full-fledged development it was necessary to be a rather experienced programmer, which thoroughly knows its programming language and can almost the entire game (including pixel graphics and special effects!) Write in simple notebook. There were few such people and they were very appreciated (and now and now) ...

Today, the threshold of entry in the subject of programming has decreased at times. And this contributes not only to the availability of literature and all kinds of training materials, but more and more simplifying development process. Nowadays, it is rare to meet real "hardcorers", since quite convenient development environments have appeared, which were called "engines".

The essence of the engine is that it allows in a simplified visual mode to import all the necessary game objects, place them on a virtual scene and configure all their parameters. That is, the task of the programmer remains only correctly to write gaming logic!

However, for the convenience of work, it is necessary to pay some increase in the size of the project (sometimes even several times!) Compared to its analogue written by the old "hardcore" method. It is for this part of the engine developers does not like or try to write their own, in which only those necessary components are used ...

But we are far from you to Tar-programmers :) Therefore, we will create a simple game for Android based on the popular and powerful Unity3D engine.

Getting started with the project in Unity3D

So, why we decided to use the Unity3D:

  • the ability to create full-fledged 2D and 3D games;
  • the ability to compile the finished game for any device;
  • relative simplicity of engine control;
  • good functionality extensibility due to plug-ins;
  • the relatively small size of the final assembly of the game (in comparison with other engines).

The main trump card is Unity3d, naturally, its versatility and multiplatform. Ready game (perhaps with minor modifications) You can port, even on a PC (with Windows, Linux or MacOS), at least on Android, at least on PlayStation or Xbox! To do this, we will need to download only the engine itself, which, by the way, "weighs" more gigabytes and the necessary SDK (if it is planned to develop for mobile platforms or consoles). If you want to make a game for Windows, you don't need to download anything else, but since we are going to make the game under android, then we will need to download more Android SDK (Software Development Kit). I advise you to download the SDK in the ZIP archive for more convenience of working with it.

When everything is loaded, you can unpack any convenient Android SDK folder convenient for you, and then proceed to install the Unity3D itself. It is installed, like any ordinary program under Windows, so there should be no problems with the installation. After installing the engine starts and we will first need to create a new project:

To do this, we will need to close all the welcoming and introductory windows, and then select "New Project" in the "File" menu. In the window that opens (see Screenshot above), we will be given to specify the Project Save folder (its name will match the project name), import some standard sets of functions (we do not need it) and specify the operation mode. As a mode, select 2D and click the "Create" button. This prepared part of the work completed :)

Project Engine and Hierarchy Interface

After creating the project, it will be loaded into the UNITY3D workspace:

This workspace itself has a modular structure and consists of several nested windows that can be moved, as you are comfortable. I have it configured so (from left to right and from top to bottom):

  1. The Hierarchy window displays the hierarchical position of active and inactive objects on the scene. By default, the only object located immediately in the list is the camera (Main Camera).
  2. The SCENE window displays the entire game scene and objects on it (including cameras, sounds, textures, etc.).
  3. The Inspector window displays all the properties of the hierarchy selected in the hierarchy or on the object scene and allows them to edit, complement or delete.
  4. The Game window - displays the game world, which is visible to the camera and allows you to choose the size of the virtual test window of the game in pixels. Also, allows you to activate the discharge of the Maximize ON Play and include / disable the display of various information for the developer.
  5. Project and Console windows. The Project window is used to navigate the project resources: loaded images, sounds, models, etc. Also using this window (context menu) you can create new empty game objects of different types and scripts. The Console window serves to display error messages (red), warnings (yellow) and various, requested by debug information (gray).
  6. The ASSETS Label window is the bottom of the inspector window, which displays the preview of the object or file selected in the Project window.

In addition to the above, pay your attention to three buttons at the top of the center. They allow you to run your project, to pause (sometimes useful when debugging to see what is being done in the hierarchy, for example) and, accordingly, turn off.

We will create a simulator of a musical instrument: Indian folk drums called the "tabla", so to get started, we will create two empty folders in the project in which sounds and pictures will be stored. You can create a new folder by calling the context menu in the project navigator window (Project) and selecting "Folder" in the "CREATE" list.

Here it is worth saying a few words about how to call these folders. For a simple game, like our simulator, in principle, the folders can be "calling" as you like, however, there are at least two names that are better not to use because they are reserved by the engine. This is the names of Resources and Plugins. In large projects, the Resources folder creates immediately and all gaming "spare parts" (pictures, sounds, models, textures and prefabs) are stored already in it (sorting by subfolders). In plugins, as follows from the name, all additional third-party features sets are saved (the so-called "assets" (assets)), which are quite a lot on the Asset Store - the extension store for Unity3D.

Import files and creation of gaming objects

Before creating a new game project, it is advisable to prepare all the files for its operation in advance. In our case, such files are pictures and sounds. Importing them to the project is the easiest way to drag into the desired folder. Let's start with pictures ...

After the images appear in our Images folder, they should be configured a little:

The fact is that by default unity3d all the pictures added to the project compresses with loss of quality. If we do not need such a loss (especially relevant for games with HD graphics), then we should select each image and in the inspector window to change the value of the "Format" parameter with "Compressed" on "TrueColor" in the "Default" tab. You may also need to change the parameter "MAX SIZE" if it is less than the real width of the picture (by default - 1024 pixels). After all changes, you must not forget to click the "Apply" button to apply them. Similar actions, if necessary, do for all other images.

Now, let's create play objects from our pictures. To do this, just drag the desired image into the Hierarchy window. The picture or the 3D model will be automatically converted to the Game Object object and are displayed at the starting point of the coordinate in front of the camera.

First of all, we added a background picture, which should be displayed in full screen. Check if it is possible to highlight the camera in the hierarchy window and looking at how its frame is displayed. In the screenshot, it is clear above that part of our background remains outside the camera view, therefore, you need to adjust the size of this review by dragging the frame directly on the scene or edit the "Size" parameter in the inspector window. In our case, I had to change the default value (5) by 5.4.

All, the camera do not touch anymore, but add and set up the rest of the pictures. When adding, we see that some of them are too big for our game. It can be reduced either physically in a graphic editor or a means of the engine. Let's try the last way. To do this, we highlight the image in the hierarchy window, and in the inspector window, change the "scale" values \u200b\u200bfor the x and y coordinate with 1 to 0.5 (that is, we reduce halfway). It is also desirable, to avoid lining, assign all game objects to all game objects (except for the background) nonzero layer order (Order in Layer):

The last step in the preparation of gaming objects from the pictures will be "hanging" on them collider (Collider). In Unity3D, colliders are used as interaction detectors between objects. That is, in fact, a virtual shell is worn to our picture, which can register touching it.

To add a collider to an object, choose it in the hierarchy window, and then in the inspector window, click the "Add Component" button. In the component list that appears, we are looking for PHYSICS 2D (the usual 3D physics in our mode will not work) and there from all the options it is most suitable for "Circle Collider 2D". I choose it. A green stroke will appear around our object, which displays the borders of the collider. It remains only to mark the item "IS Trigger" to make our collider only register the press and no longer interacted with the surrounding game space:

Similar actions repeat for all remaining objects. Different from other objects will be only our background. For him, we apply Box Collider 2D and exhibit Position Z more zero to push the collider and the background itself to the background (this is useful to us a little later).

Work with sound

With sound in Unity 3D at first glance, everything is somewhat confused. But we will try to figure it out in order :)

First of all, we need to drag all the sounds into the Sounds folder and configure them too:

If the volume level of all sounds is initially adjusted, then everything that needs to be done is to turn off 3D sound processing. In three-dimensional games, this processing is needed in order to imitate the approximation of the sound source when the camera approaches it. But in 2D, we can do anything, so we allocate each sound in turn and remove the "3D Sound" checkbox.

Now we can proceed to add sounds to game objects. To do this, we need to highlight each button in turn and add it a new "Audio Source" component from the "Audio" section. When the component is added, select the corresponding button "Audio CLIP" and remove the default "Play On Awake" checkbox (play when you appear):

When all the sounds are attached to the right buttons, the time will come for the most interesting - script ...

First script

Before starting to disassemble our first script, it is probably worth a couple of words to say about the script system itself in Unity 3D.

Uniti allows you to write code immediately in three languages: javascript (more precisely, its slightly modified UNITYScript version), C # and Boo. In a number of books and manuals, you can find the opinion that for beginners, the scripting in Unity is easier to master on the example of JavaScript. However, this language is not so comfortable as the rest, and in the future you will most likely have to be retracted. Therefore, it is better to immediately start with the study of C # (Boo is also not bad, but there are few educational materials on it).

Now about where to write code. By default, the code in Unity is IDE Monodevelop. The advantage of this development environment is that it has tips to quickly enter standard methods, classes and functions, as well as the syntax check system. However, the minus for me was cumbersome and high resource intensity. Fortunately, in the Unity settings, you can install as a text editor, anything, so I "suspended" easy and functional NotePad ++ (almost all examples will be shown in it).

And last. Naturally, without reference materials in the development of all wisdoms, you will not go far, so here is a list of several sensible Internet resources on Unity 3D:

  • http://docs.Unity3d.com/ru/current/manual/unitymanualRestructured.html - the official manual on the engine with a partial translation into Russian (it appeared recently and while it works unstable);
  • http://docs.unity3d.com/ru/current/scriptreference/index.html - Official Manual-Directory for Scripting in English;
  • http://unity3d.ru/distribution/index.php - Russian-language developer forum under Unity 3D;
  • http://habrahabr.ru/post/141362/ - cycle of lessons to create three-dimensional games in Habrahabre;
  • http://msdn.microsoft.com/ru-ru/library/618ayhy6.aspx is the official C # handbook from Microsoft in Russian.

Well, in order not to pull it for a long time, I propose to immediately create the first script. Under scripts, if there are many more, it is better to highlight a separate folder, but we will have a simple game, so we can create a script directly in the root folder of the project. To do this, call the context menu in the Project window, select the Create list and click "C # Script". Let's call our new script, for example, Sounds and open it with a double mouse. Removing the standard methods of Update and Start, and then, speaking the desired we obtain the following type of script:

If you did not reconfigure the editor, then our script will be opened in Monodevelop. We will analyze his structure ...

In fact, each script on C # consists of three main parts:

  1. At the very top, the libraries are listed that you need to connect to the script operation (for example, "using unity.engine" connects to the operation of the engine itself, and the "Using System.Collections" is a library containing a number of embedded classes for the script operation under different systems).
  2. Class and variable declaration. In C # there is no concept of a script, as such. Instead, the concept of "class" is used, which includes a number of methods and functions. Although, in fact, in the context of Unity 3D, it is almost the same thing :) The main thing is to remember that the class name must match the name we gave the script. The feature of the variables in C # is that they are necessarily (except for the temporary, which are declared in the script itself) must be typed. In practice, this means that the access level should be specified for the variable and the type (int, float, bool or, or as we in the script, AudioClip. In this case, the variable name can be given any. And I can immediately and value attribute.
  3. Set of methods and functions. The method in C # is virtually any feature that performs certain actions. In principle, in the literature on the Unity 3D, they are called functions, but if we are talking about C # as a separate programming language, it is, the methods :). Functions in pure form in UNITi are, for example, standard sound output functions, drawing GUI elements, etc., which are used inside methods.

Knowing now the structure of the script, it is not difficult to understand its meaning, which comes down to the next ... in the class (script) Sounds we declare 9 variables of the type of AudioClip with the names of them for the convenience of distinguishing them with names. We make them necessarily public (private will not be displayed in the editor, and we will need to "hang" sounds through the editor). And then in the body of the script we use the standard "void onmousedown ()" method. Previously, he only answered the handling of clicking with the mouse, but in new versions is interpreted and as touching the touchscreen. We write the conditions for which we check the names of the closed colliders and, if we find the press of one of them, output the corresponding sound (we use the standard Audio.Playoneshot () function);).

When writing the code, you carefully follow the presence of all opening and closing brackets otherwise you will constantly receive error reports in the console and you cannot start your project at all! Also pay attention to the use of the methods and functions of capital letters. They are also often caused by mistakes. And, naturally, keep all the signs (points, colon and brackets), shorter, language syntax. First it will be difficult, but over time you will start writing from scratch without errors!

When the script is ready, select it in the inspector window, assign your sound from each variable. Now we have only to apply our script to objects on the scene. The easiest way to do is, again, by dragging the script directly to the right gaming object in the list of hierarchy:

If the script was dragged correctly, then it should appear in the inspector window at that object to which we dragged it. Accordingly, dragging the script to all objects that should sound in the game and can try to run it. When you click on our game buttons now, finally, the specified sound will sound!

Introduction to GUI.

In principle, the game has already functioning, but some kind of bald ". There is not enough something in it ... And, at least, the inscriptions with the title that is in front of us! In other words, you need to implement any distinct user interface.

Actually, GUI is a reduction from the English. "Graphical User Interface", that is, the graphical user interface. Traditionally, it includes such components as:

  • buttons;
  • window;
  • text areas;
  • chekboxes and / il radiocans;
  • sloters (scroll bar), etc.

In Unity 3D, all this (and even something over that) is fully present. The main thing is to learn to use it! Consider how the GUI means in unity can make a simple headline inscription.

To do this, create a new script named Interface and change it as follows:

Consider the script closely in the screenshot. Here we will write only one public variable new for us type Guistyle. This type allows in visual mode to change the design of the items to which this style is assigned. Styles are convenient to use if there are many elements of the interface of the same type (for example, buttons), but they should have a different look.

Next, we create a button ("GUI.BUTTON"), which has the following syntax: Condition - 4 coordinates (indent horizontal from the left edge, indent vertical from the top edge, width, height) - visible text in quotes and further, optionally, Entrance style. Inside the conditions of the button, the necessary functions are prescribed. In our case, we prescribed the transition to the developer site ("Application.openurl ("); ").

Scripts with GUI can work with any game objects, but usually they advise "hang" to the camera that we will do, dragging the script to the Main Camera object. Now, if you are highlighted in the hierarchy window, in the inspector window we will be able to see a public variable of our style, deploying which, we will receive full access to the settings of this style!

We can specify the color of the text and the texture for the background in any situations (for the button you need to register three of its options (Normal - normal view, Hover - when you hover and Active - when you click), set indents and configure the font. By default, the only available in Unity 3D The font is Arial, however, you can manually load any other in the project and apply it in the Font field by configuring all related parameters.

What is interesting and at the same time is not entirely convenient, the GUI elements are not displayed on the scene until we start the project, so the adjustment of the parameters of each element may take a lot of time. Let's start the project and see how our button created above will look like:

Change interface for condition and static variables

We have already done a lot, but there is always a lot to improve :) Therefore, I propose as the last example to create a reference window, which usually normal developers provide their games and applications. To do this, add a picture to a folder with images for such a button as a question mark and make a gaming object from it. We can hang a collider on it and write a script with a name, for example, "HELP" as follows:

In this script we have two variables. The first variable defines the skin that will be used for all interface elements described in this class. Unlike styles, the work with which we looked above, the skins allow you to change the appearance of not only a separate item to which they are attributed, and all elements of a certain type immediately. In addition, unlike styles, the skins are not prescribed to the elements, but are declared immediately for the entire method and work until another skin declared. It should also be remembered that the skins exist not only in the form of variables, but also as separate files. Therefore, before declaring the skin, you need to immediately create it in the "Project" window from the context menu: "CREATE" - "GUI SKIN".

The second variable is logical (or in a different bulev). It can only have two values: "Truth" (True) or "False" (FALSE). By virtue of its binary nature, such a variable is perfect for the implementation of all sorts of switches. In our case, it will be responsible for displaying text with the description of our game.

However, if you look attentively, you can see that the last variable has one wonderful parameter - "Static". Adding to variables of such a parameter allows you to make them static and accessing them from other scripts!

But back to the rest of the code. Already familiar to us "void onmousedown ()" method here will serve as a switch of the variable "isvisible" using a simple condition. However, after the condition there is another feature. This feature ("debug.log ();") serves to output "on the fly" into the console of the values \u200b\u200bof the variables we need (we enter without quotes in brackets). As you can see, inside the function, you can combine both unchangeable text (written in quotes) and variables (without quotes). The main thing is that only the "+" sign between all data.

Next, on the script text, we have a method of drawing an interface ("void ongui () ()"), within which we see an ad new skin ("gui.skin \u003d helpskin;") and a new element of the GUI.Box type interface. Unlike a button, boxing is an inactive element and is usually used to output various text or graphic data.

Pay attention to how we set the positioning for boxing. Here, all values \u200b\u200bare not directly indicated, but with the help of mathematical expressions, which, in fact, is an analogue of a "rubber layout" in web development. The problem is that when specifying the exact dimensions of the GUI elements with different screen resolutions, they will not adapt and can be either too small, or, on the contrary, large. In the next version, the engine developers promise to make GUI adaptive, but still have to be perverted: (

The last step towards success will be the configuration of our skin. In the script variable, specify the skins file, and then select this file in the project window. As for other files, the skins settings will be displayed in the inspector window. Here we are looking for the element that is subject to change (in our case Box), we reveal it and configure the same style similarly to the above:

To see whether our script works correctly, start the project and try to click on the help button:

Now everything works, but it is not always convenient to press the help button to hide the description back. More familiar to the disappearance of all notifications to poke into any free space than to aim in the buttons. And here we are just useful to us that we made a variable "Isvisible" static, as well as hung on the background picture of the collider ...

Let's go back to our first script ("Sounds"), which kept pressing the buttons to play sounds. In it (more precisely, inside the method "void onmousedown ()"), we will sufficiently prescribe only one line:

if (this.name! \u003d "HelpButton") (help.isvisible \u003d false;)

With this line, we specify the condition: if the name of the pressed collider is not equal to the help button name, then the "ISVisible" variable in the "Help" script will be "false". It is only necessary that the variable "isvisible" accurately had a "static" prescription, otherwise we get a mistake.

Now at startup, we will see that our help window closes when you press not only the button in the upper right corner, but also when you touch any free part of the screen. The only thing that can be improved is to make that the window is hidden and by clicking on it itself ... It will be your "homework";) I will only say that the GUi-box will need to change the same-decorated button, again, with the setting Skin and prescribing a function that changes the variable "isvisible". All, then silent :)

Compiling game and save project

Finally, everything works with us! This means that it's time to keep our game and test on the real device. And for this it needs to be compiled into the executable file (for Windows, for example, in EXE, and for Android in APK).

If you want to compile the game for a PC, you do not have to make any preliminary settings. However, for android, you will need to first connect the downloaded by us at the very beginning of Android SDK. This is quite simple: we go to the "Edit" menu, call the "Preferences" item and in the window that opens, go to the "EXTERNAL TOOLS" tab. Here we are looking for a string "Android SDK Location" and in it specify the path to the unpacked archive with SDK (see Screenshot below). By the way, here you can change the active default MONODEVELOP text editor to your favorite :)

And now the moment of truth is the moment! We go to the "File" menu and looking for the "Build Settings" item. In the window that opens, we will need to immediately add scenes to build. If the scene is one (as in our project), then it will be enough to click on the "Add Current" button. If there are several of them, then it will be necessary to open each of them and make a similar way to the list of scenes, and then by dragging to configure the order you need:

The next step is to choose the assembly platform (we are planning the game under Android, it means that it is chosen) and press the "Player Settings" button downstairs. In the inspector window, a number of settings from which some are mandatory or very desirable are open. It is desirable to specify the names of the developer company, the program and its icons (Company Name, Product Name and Default Icon, respectively) at the top of the list of settings.

At the bottom of the same part in the "Other Settings" section there are two required parameters: "Bundle Identifier" and "Bundle Version". The default version is affixed as 1.0, but the identifier will have to be created manually and, preferably unique. It should consist of three parts separated by dots: the reserved word "com", then the name of the developer's company, and at the end the name of the application itself.

The remaining assembly settings can be changed at your own or not change at all. The main thing is that now the compilation can already be started. To do this, it is enough to press the "Build" button in the "Build Settings" window and wait until the programs give us a ready, packed in APK file application :)

Conclusion

On this, our lesson-overview for creating the simplest applications for Android comes to an end. In order for you to repeat everything we talked about, at the end of the article I will give a link to the archive, in which all the game resources will be stored in the form of a separate folder (if you want to do everything from scratch) and as a file with the UnityPackage extension. The latter allows you to import all the project in Uniti at once, including dependencies, etc.

To import our project (and, by the way, any plugins downloaded from the Internet or Assets Store) need to go to the "Assets" menu, select "Import Package", and in it "Custom Packe", after which you specify the path to our file and Press the "Import" button. By the way, make a full backup of your project, with saving in such an unitypackage you can from the same menu ("Assets") by clicking on the "Export Package" item.

It seems, everything :) As a person who mastered Unity 3D from scratch, in the article I tried to give answers to the maximum number of questions and highlight the main nuances of working with the engine that arise at first. But, perhaps, someone will be not enough, so if you have any questions, you can handle either directly to me on the mail, or on the forum: what can I help!

I wish you all good luck and successful implementation of all projects!

P.S. It is allowed to freely copy and quote this article if you specify an open active reference to the source and maintaining the authorship of Ruslana TRADER.

Unity 3D will be an indispensable assistant for those who professionally approach the task of creating quality material. The application integrated ready models, scripts and textures that can be supplemented with your own content - images, sounds and video recordings.

Finished products created in Unity 3D are compatible with almost all popular platforms - ranging from mobile phones and ending with Smart TV TVs.

Program capabilities:

  • learning Unity engine;
  • flexible multifunctional editor;
  • high compilation rate;
  • easy in mastering the interface;
  • compatibility with a large number of platforms.

Principle of operation

To use the program, you need to download the Unity Hub platform, and you can try the functions of the free version of Personal through it. It is available at the volume of monetization of up to 100 thousand dollars annually.

In addition to the free option, you can subscribe to two other extended versions:

Unity Plus (~ $ 25 Monthly) - provides limited access to the Customer Success Advisor service, collects information about failures on user devices, monitor reviews.

Unity Pro (~ $ 125 Monthly) - maximum subscription option. Provides support from professional developers, it allows to obtain priority access to support from the program creators, includes improved features for monitoring performance and collect statistics.

Building all gaming actions is based on a fairly high-quality physical core of the program (PhysX), from which the behavior of models depends. Due to the possibility of importing textures and objects, the product can be given uniqueness or use the tools integrated developer. It is important to understand that each object created in this designer is a specific set of scripts and events, which can be managed independently.

For professional work with Unity 3D, it is necessary for some time to get acquainted with the interface and the capabilities of the application. To do this, on the Internet you can find a lot of rollers or visit specialized courses, which are held in many major cities.

It should be noted that to work with 3D graphics you need to have a modern computer with a hardware video card.

Pros:

  • practically limitless functionality to create projects;
  • support for browser 3D graphics;
  • compatibility with game consoles and modern TVs;
  • a large number of visualization tools;
  • there is a free version.

Minuses:

  • to create a high-quality product, specific knowledge is needed;
  • there is no possibility of very fine configuration of the physical core of the program;
  • there is no interface translation into Russian.

You can download UNITi 3D not only to prepare a competitor to a popular online jaggernaut toy (which is also drawn by the tools of the hero of our review), but also to create chic three-dimensional presentations. Let it take a little longer, but the Wow effect for the audience is guaranteed.

To meet the capabilities of the platform, it is enough to download the free version of Unity 3D. If you need access to the source code, take a look toward the paid versions.

Analogs:

  • Game Editor - a free app to create games;
  • CONSTRUCT 2 is a popular game designer, distinguished by a simple interface.
  • CONSTRUCT 2 is a powerful program for creating 2D projects.

How to quickly write a game for android on unity

At this time, everyone can become a successful developer of mobile games or applications, without applying to this titanic effort. An example of such a case is Dong Nguyen, which developed Flappy Bird. There was no difficult mechanics or graphics in the game, but it did not prevent her from becoming popular and bring to his creator fifty thousand dollars a day. However, there was nothing remarkable in the game. All that needed to succeed is to be in the right place at the right time and a little good luck. This can happen today today, you just need the right idea.

To demonstrate how easy it is to write something like this, today we will write our Flappy Bird using Unity in just 10 minutes.

Game Character

First create a new project and make sure that the 2D option is selected.

Load your sprite birds in the scene. Do not forget to turn on the fantasy!

Then adjust the size of the sprite as you like while dragging it with the corner in the right direction. Sprite should be visible in the hierarchy window on the left. All objects in the scene are visible in it, and at the moment there should be only two: a camera and a bird.

Drag the camera on the bird and release. The camera should be under the bird, it will mean that the camera is now a "baby" birds. Now the camera's position will be fixed relative to the bird. If the bird moves forward, then the camera does the same.

Select a bird in the scene or in the hierarchy window. You will see a list of options and attributes on the right in the window called Inspector. Here you can control various variables tied to a specific object.

Now click on Add Component. Select Physics2D\u003e Rigidbody2D is a ready-made set of instructions for applying gravity to our character. Click on Constraints in this panel and then select Freeze Rotation Z. This will prevent the bird's rotation along with the camera in a circle.

In the same way, add Polygon Collider, which says Unity, where the character borders are. Click Play and see how sprite with the camera endlessly drops down.

While everything goes well!

Now it's time to go to the character flights, good it will be easy.

First you need to create C #-script. Create a folder for it (right-click anywhere in the Assets and create the "scripts" folder, make the right mouse button and select Create\u003e C # Script.

Let's call it "Character". Click on it twice to open it in your IDE, whether Monodevelop or Visual Studio. Then add the following code:

Public Class Character: Monobehaviour (Public Rigidbody2D RB; Public Float Movespeed; Public Float Flapheight; // This is necessary to initialize Void Start () (RB \u003d getComponent ();) // Update is called once per Frame void update (RB .velocity \u003d new vector2 (MoveSpeed, Rb.Velocity.y); if (input.getmousebuttondown (0)) (RB.Velocity \u003d New Vector2 (RB.Velocity.x, Flapheight);) if (transform.position.y\u003e 18 || transform.position.y.< -19) { Death(); } } public void Death() { rb.velocity = Vector3.zero; transform.position = new Vector2(0, 0); } }

This code makes two things. He causes the character to move forward at the speed we define in the inspector, and creates a feeling of bird flight. The UPDATE () method is called again throughout the game, so everything you put here will be performed continuously. In this case, we add some speed to our object. The RB variable is the rigidbody2d script, which we applied to our object before, so when we write RB.Velocity, we appeal to the speed of the object.

Tap on the screen is interpreted by Unity as a mouse click if you use a mobile device. After pressing, we force the character a little climb up.

The MoveSpeed \u200b\u200bvariable will be responsible for the speed of movement, and the FLAPHEIGHT variable is for an increase in the height of the bird flight after each press. Since these variables are declared as public, we will be able to change them outside the script.

Death () method is also declared as Public, which means that other objects and scripts will be able to call it. This method simply returns the character's position to the beginning. It will also be used every time the character will fly too high or low. Soon you will understand why it is declared as Public. Row rb.Velocity \u003d Vector3.zero; Need to remove the pulse - we do not want after each death the character fell faster and faster?

Now you can leave the IDE and add a script as a component to the character. To do this, you need to choose our bird and click Add Component\u003e Scripts\u003e Character. Now we can define MoveSpeed \u200b\u200band Flapheight in the inspector (for this and need Public-transferred). We assign variable values \u200b\u200b3 and 5, respectively.

And more: in the inspector you need to add a tag to the character. To do this, click where Tag: Untagged is written and then select Player in the drop-down list.

Obstacles

Now add obstacles: pipes. Someone in the pipes finds mushrooms, and someone is their death.

Drag the sprite of the pipe into the scene to the place where the first obstacle should be, and name it is Pipe_UP.
Now create a new script called Pipe:

Public Class Pipe: Monobehaviour (Private Character Character; // It is necessary to initialize Void Start () (CHARACTER \u003d FINDOBJECTYPE ();) // Update is called once per Frame Void Update () (if (character.transform.position.x - transform.position.x\u003e

Add this script to the pipe sprite in the same way as before. Thus, the pipe will return to the screen after going out for its left border. We have not done anything here, but we will return to this.

ONCOLLISIONEnter2D () method is called each time the pipe interacts with the character. After that, the Death () method created by the previously created player in the starting point is called.

So, we have one pipe, which from time to time will disappear and appear on the other end of the screen. You will die in her - die.

Inverted pipes

Now we have only one sprite pipe. Let's add one more. To do this, right-click in the hierarchy window, click New 2D OBJECT\u003e SPRITE and then select the sprite you want to use. Even easier will simply drag the file to the scene again.

Name this sprite Pipe_Down. In the inspector in Sprite Renderer, select the Flip Y option to turn the pipe upside down. Add the same rigidbody2d.

Now write a new C # script called Piped. In it will be similar code:

Public Class Piped: Monobehaviour (Private Character Character; // It is necessary to initialize Void Start () (CHARACTER \u003d FINDOBJECTYPE ();) // Update is called once per Frame Void Update () (if (character.transform.position.x - transform.position.x\u003e 30) ()) void oncollisionenter2d (Collision2D Other) (if (other.gameObject.tag \u003d\u003d "Player") (character.death ();)))

Prefabs

So, we have enough of this code to make the whole game. We could move the pipes on the right side of the screen every time they disappear, or copy and insert so many pipes as we would like to meet throughout the game.

If you go first, then make sure that the pipes are standing after random generation, and it would be difficult to maintain the honest stroke of things. After the death of the character, they could appear in kilometers from the first pipe!

If you go second, then everything will end up excessive consumption of memory, with a slowing down of the game, and limited to playing, because Everything stands on the same places every time.

Instead, let's use prefabami. If we say simply, we will turn our pipes into templates, which then be able to use to effectively create a larger number of pipes at will. If there are programmers, consider the Pipe class script, and the pipes are instances of this object.

To do this, create a new "Prefabs" folder. Then drag the Pipe_UP and Pipe_down from the hierarchy window to the folder.

Each time you drag the object from this folder in the scene, it will have the same properties, so you will not need to constantly add components. Moreover, if you change the size of the component in the folder, it will affect all pipes in the game, and you do not have to change each one separately.

As you understand, it will save our resources greatly. It also means that we can interact with objects from the code. We can create copies of our pipes.

First add this code into a conditional expression in the UPDATE () method of the Pipe script, which we left blank:

Void update () (if (character.transform.position.position.x - transform.position.x\u003e 30) (float xran \u003d random.range (0, 10); float yran \u003d random.range (-5, 5); instantiate (GameObject, New Vector2 (Character.transform.position.x + 15 + Xran, -10 + Yran), transform.rotation; Destroy (GameObject);))

It is necessary to create an instance of our GameObject. The result is a new identical copy. In Unity, always when you use the word GameObject, it refers to the object to which the script is currently tied to - in our case to the pipe.

We generate rebound pipes in random variations to be more fun.

But instead of making it all the same in the Piped script, we generate both objects in one place. Thus, we can easily install the position of the second pipe relative to the first. It also means that we need less code for Piped.

Create a PUBLIC GameObject with the name Pipedown. Then update the code as follows:

If (character.transform.position.x\u003e transform.position.x\u003e 30) (float xran \u003d random.range (0, 10); float yran \u003d random.range (-5, 5); float gapran \u003d random.range (0, 3); Instantiate (GameObject, New Vector2 (character.transform.position.x + 15 + xran, -11 + yran), transform.rotation); Instantiate (Pipedown, New Vector2 (Character.transform.position.position.x + 15 + XRAN, 12 + Gapran + Yran), transform.rotation; Destroy (GameObject);)

Returning back to Unity and drag the Pipe_down prefab from the prefabami folder (this is important!) To the place where "Pipe Down" is written (notice, as our Camel Case is replaced by a space) to the Pipe Up pipe sprite. If you remember, we defined the Pipe Down as Public GameObject, which gives us the opportunity to determine what this object is from anywhere - in this case through the inspector. Choosing a prefab for this object, we are convinced that when creating a pipe instance, it will include all the attributes and the script that we have added earlier. We do not just create sprite, but re-create an object with a collider who can kill the character.

All that we add to the same place in the Piped script is simply DESTROY (GameObject) so that the pipe is self-disperse when the screen left the left border is released.

If you start the game now, the screen will come further automatically, and you will die if you encounter any of the pipes. Flip far enough, and these pipes will disappear and appear ahead again.

Unfortunately, there is a long distance between the pipes, and the screen looks empty. We could fix it by adding several prefabs to our scene to create a conveyor constantly appearing pipes. However, it would be better to generate pipes in the script. This is important, since otherwise, after the death of the pipe character, it is destroyed at the beginning of the path, and an empty space is formed again.

Thus, we can create several first pipes during each game loading and return everything in our place after the death of the character.

Infinite flight

Now let's create Public-transmitted Pipe_UP and Pipe_down in the Character script. This will give you the opportunity to refer to the created objects, dragging the prefabs to the character object, rightly as when we added Pipe_down to the Pipe script.

We need to add these variables:

Public GameObject Pipe_up; Public GameObject Pipe_down;

Then we will write this method:

Public Void Buildlevel () (Instantiate (Pipe_down, New Vector3 (14, 12), Transform.Rotation); Instantiate (Pipe_UP, new vector3 (14, -11), transform.rotation); Instantiate (Pipe_Down, New Vector3 (26, 14), transform.rotation); Instantiate (Pipe_UP, new vector3 (26, -10), transform.rotation); Instantiate (Pipe_Down, New Vector3 (38, 10), Transform.Rotation); Instantiate (Pipe_UP, New Vector3 ( 38, -14), transform.rotation); Instantiate (Pipe_down, New Vector3 (50, 16), Transform.Rotation); Instantiate (Pipe_Up, New Vector3 (50, -8), Transform.ROTation); Instantiate (Pipe_Down, New Vector3 (61, 11), transform.rotation; Instantiate (Pipe_UP, New Vector3 (61, -13), transform.rotation);)

We will call it once in the Update () method and once in the Death () method.

After the start of the game, Update () is called, and our pipes are set according to a given configuration. Due to this, the first few obstacles will always stand in the same place. After the death of the player, the pipe will fall on the same places.

Return to the Scene in Unity and remove the two pipes that are there now. Your "game" will look just like a blank screen with a bird. Press Play and pipes will appear, after the first few of their position will be determined randomly.

Finally

So we made a whole game! Add the points meter, try to make it more original and increase the complexity of the game as it is promoted. It will not be superfluous to make a menu. Another good idea will destroy the pipes on the screen after the death of the character. As soon as you finish with this - consider what is ready for release in the Play Store game in your pocket! Once like a similar game made another developer very rich, and this proves that you do not need to be a genius programmer or have a rich publisher for your back to achieve success. You just need a good idea and ten minutes!

Want to write applications for Android, but do not know where to start? Then familiarize yourself with our great to explore Android development.