Working in Unity3d: the basics of creating games. Working in Unity3d: The Basics of Making Games How to Create Games in Unity3d

  • 30.12.2020

Unity is the game engine on which the most of modern games on different platforms. By means of the engine, it is really possible to create games aimed at launching on computers (Windows, Linux, MacOS), mobile phones, tablet computers (Android, iOS, Windows Phone) and even game consoles PlayStation, Xbox, Nintendo.

It's impossible to imagine creating games on the Unity engine without writing additional code. Unity supports two programming languages ​​- and. Previously, the Boo language was also supported, but later dropped.

You can independently choose which language to program in Unity, as it does not really matter. Most developers give preference to the language, as it is more powerful and it is much easier to find various documentation than for the language.

Unity uses built-in functions that are not found in C # or JavaScript. Due to this, it doesn't really matter whether you know the programming language or not. However, we still recommend taking the C # language course first. The course is presented on our website by.

Course plan

During the course we will create a simple game called "Roll a Ball". The game will have a ball that can be moved using the arrows on the keyboard. When moving, the object will be able to absorb other objects on the surface, thereby collecting points.

The course is introductory, so no knowledge is required before taking it. After the course, you can review more advanced programs. All programs are presented on our website.

Hello everyone! Having learned how to make games on this engine, I want to teach you the same. First, we need Unity3d itself, any 3D model editor and straight arms growing from the shoulders.

1. Studying the program

First, I recommend installing Monodevelop! Let's see what Unity is. Unity is a multi-platform game development environment. It is because of its simplicity and clarity that every third person has made games on it at least once.

Consider the screen above:

  • The stage is your sandbox for creativity.
  • Project - all animations and models, sounds and textures are located here.
  • To install models in the upper toolbar, select Assets-Import New Asset. Alternatively, Assets-Import Package-Custom Package. In the second case, the package must be in the .unity extension.
  • Hierarchy - all objects in the scene. There you create parents for the object. Just move an object to another in the hierarchy menu, and it will snap. The end result is a kind of folder.
  • Toolbar - a list of instruments. There you can enable 2D, 3D mode.
  • Inspector is a characteristic of an object, where you add animations, scripts, and more. There you can use tools: moving the camera, moving the object, stretching, rotating the object.


Now you see the object menu in it, you can add animation, scripts and more.

I think that you will have no problems with this menu.
To create any object, click.

In general, we have studied the program; soon it will be possible to write our own games.

2. Making the simplest game

First, let's create a Create-Terrain. Add grass and trees. By clicking on the ground on the right, a window will appear, select trees, grass.


Also create mountains and bumps. Then load the Characher controller pack into your project. Then we search in the window with the Standart assets-Characters controller project and choose the first person view (capsule) or the third person (mechanic).
If the first person, then just put it on the ground. If from the third, then you need to load the animation. I also recommend setting lighting on the Create-Directional Light scene.


To add music, drag it to the desired object.
The game is ready, but how to compile it?

To do this, go to File-Build settings-player settings (for shortcut and title). Choose your platform and voila, you're done. To do this, you need to install the Android SDK. But there you need to specify the folder with the SDK, and you need not just the SDK, but the API of the required level (for example, Android 4.2 has API 17). For example, for the game to run on Android 4.0+, you need to install these APIs.

In the next article I will tell you how to set up controls for Android or iOS and learn how to write scripts yourself.

Development of mobile applications is one of the most lucrative pursuits in the computer industry. It costs several hundred or thousands of dollars to create a game on Android, and the profit can go as high as a million dollars. In this regard, many people are interested in developing applications for the phone. In this article, you will learn how to create a game for android from scratch via a computer, which engine and constructor is better to choose.

None successful game not without beautiful graphics, therefore, design creation is one of the most important stages of development. Android design is implemented using a "design document" or design dock. You need to start creating a toy precisely with its detailed study. The file contains:

  1. Object Models;
  2. Functional specifications;
  3. Game content;
  4. Interface.

Let's consider each of the points in more detail.

Object Models

This is information about the functionality of each item. Object models are responsible for the ability to buy and sell items, as well as for improving game characteristics characters.

Functional specifications

It describes the gameplay, the main features of each character. It also provides a description of the features of in-game items - weapons, first aid kits, armor and others. Essentially, functional specifications are the rules by which game process... The better this section is worked out, the easier it will be to create a high-quality Android game.

Game content

This is the text filling of the game. It describes the dialogues of the characters and what weapons can be used to inflict damage, how much health a hit will take, what characteristics will increase when using various equipment. It also contains detailed description each item.

Interface

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

Game engine

The core of any game is the engine. This software allowing you to develop and run it. It contains a whole suite of programs including rendering engine, physics engine, sound, animation, and more. To ease the process of writing programs, third-party developers create their own game engines specifically for Android applications.

Each of them offers different functions: some are designed for 3D, others for 2D, multi-platform support can be supported. There are a huge number of such engines, but if you are a beginner, it is better to choose one of the most popular, since all the necessary functions will be present there.

UDK

Torque 2d / 3d

What is a game constructor?

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

The constructor allows you to create games of various genres for Windows, Android and iOS. Offers a large selection of ready-made locations, objects, characters and sound design, so it won't take long to create the first Android game. Users familiar with JS and C ++ programming languages ​​can use embedded GML. The only drawback is that the program is not translated into Russian.

Conclusion

Creating a game for Android is not an easy, but very profitable business. If you decide to develop a game and make money from it, first work out the idea. Next, write a "design document" and decide on a game engine that can maximize its potential. After that, you can start directly creating the application in the designer.

Video

To learn more about the process creating android games, check out the video series for this lesson.

We have already covered the history of the Unity engine and its advantages in the article "". In short, this technology is incredibly popular among indie developers, as well as a number of large studios that create games of various genres on it. Below, we'll take a look at some of the best projects that Unity has spawned.

10th place

An original indie first-person shooter created by the eponymous Superhot Team. As a small demo for competition 7 Day FPS Challenge, the game has grown into a demo , and then moved to Kickstarter, where she received the necessary funding and subsequently became a full-fledged game.

In appearance makes a nondescript impression: the graphics are made in a minimalist style (red faceless opponents on a gray background), and the gameplay offers only one thing - to shoot opponents. However, the uniqueness lies in the shooting itself, or rather, in the way it takes place.

So, when you move, time in SUPERHOT flows as usual, but as soon as you stop, everything around freezes. Stopped time will allow you to look around and figure out the further course of action in order to make a beautiful streak of murders. But if you catch at least one bullet, you will die.

9th place

Another indie game created by by Failbetter Games. By itself, Sunless Sea is not iconic and does not offer unique items. We decided to add it to the list only because, in general, the game is made with high quality, and its genre - roguelike - is today in pure form almost impossible to find in the vastness of the gaming industry.

Having raised funds on Kickstarter, the developers decided to release a spin-off to their own browser-based RPG Fallen London. All the action of Sunless Sea develops in the same universe and in the same time frame - the scenery of the Victorian era, which has absorbed mystical themes and fantasy like the legends of Cthulhu.

To play the same in Sunless Sea was to be the captain of the steamer, who travels to various islands of this world and faces all sorts of obstacles.

If you want to play a game with a wonderful world, well-crafted scenes and good plot, not inferior to serious books, then you will definitely like Sunless Sea.

8th place

An MMO simulator in which players need to jointly control a huge airship. Guns of Icarus Online is designed in the style ... You will not find any world or description of the universe in this game - everything that happens takes place in the faceless heavenly spaces, where combat airships collide.

As a session game, the game offers gamers to participate in online battles both 1 on 1 and in the form of massive battles. However, 1 on 1 is a conditional concept, since each one is represented by four real players.

Before the start of the battle, each of the four must choose a specialization: the class of a pilot, marksman or engineer. True to their name, specializations are focused on different tasks and have unique characteristics.

During battles, the entire team of players is on the airship and performs their duties. As an engineer, a gamer can take the helm of the pilot or sit on the cannon. The pilot, in turn, no one bothers to go to repair the broken object.

The difference lies in the debuffs and buffs that are applied depending on the class and the player's actions (the pilot controls better, and the engineer repairs faster).

Guns of Icarus Online features many unique airships, each with its own firepower and characteristics. Victory will be achieved by the team that sends the enemy equipment into free flight - i.e. will destroy.

7th place

The project, which caused the hype bacchanalia in 2016, which swept the entire Internet, has infiltrated television and newspapers. is an free game for mobile devices, in which the player needs to collect famous monster characters from the Pokemon universe.

The key feature of the game is based on augmented reality technology, which, using an Internet connection and a video camera, determines the user's location and projects the Pokémon themselves on the screen, which seem to be in reality at that time.

However, only Pokemon Go managed to get a loud response from the public - the game was downloaded by more than 100 million people from all over the world. Niantic also managed to earn about half a billion dollars.

6th place

Campo studio released an interesting indie project in 2016 - a game of with a first-person perspective that tells the story of a common man named Henry and his troubles that spawns modern society.

The game takes place in the Shoshone forest in 1989, just at the time when the Yellowstone fire began. Main character Henry, who has lost his beloved wife, decides to abstract himself from society and go into a hermitage, becoming an observer of the forest on one of the fire towers.

The whole plot is based on the communication between Henry and Delilah's girlfriend, who is on the other side of the radio during the entire passage. The relationship of characters, as well as the problems they raise, is the essence of Firewatch.

5th place

Obsidian Entertainment continues its own trend of resurrecting the "old school" role-playing games... After the successful Pillars of Eternity, the developers set about is a project of the same genre that tells a completely new story.

Like PoE, which we also recommend you play, Tyranny is made on the Unity engine. In technical terms, the game (like all of the above) does not offer anything new - this is the use of all the same technologies of the border of the 1990s and 2000s, which were at one time used in the CRPG.

As you become familiar with the genre, you will encounter familiar party gameplay and pause. Difficult battles await you, in which you need to use all the skills of the heroes, and the branched plot and dialogue that are the main highlight of Tyranny. Recommended for fans of Baldur's Gate and Planescape: Torment.

4th place - Rust

In the endless odorous goo called Early Access Survival Simulator, it's very hard to find anything worthwhile other than the odorous goo itself. However, there are still exceptions, as Rust eloquently declares to us. This "survivalist" primarily differs from hundreds of similar clones in that it became one of the first of its kind.

Rust

The Rust project has been in Early Access for a long time (since 2013), which in fact ranked it among the damned camp of "alpha games" that were never destined to come out. Nevertheless, the game has been updated for so long and has acquired so much content that it was in early access more at the whim of the developers than due to technical reasons. Finally, on February 8, 2018, the game was officially released.

In general, all the craziness with games in early access in started with DayZ, which fell on the industry like a bolt from the blue. It was on her that the Rust developers were guided, however, they soon decided to move away from the original idea and mix the features of DayZ with Minecraft.

Actually, the essence of Rust lies in the genre itself - you need to survive. The game works exclusively in online mode, so you have to interact with other players.

You will find yourself on a huge island with only one purpose - to survive. Well, to survive, you have to collect resources, craft various things from an ax to a pistol, build bases, fight other gamers, and so on.

We would not have placed her in the top if, as mentioned above, she had not become one of the pioneers of the genre. A quality game that managed to sell more than 5 million copies by 2016, which speaks in large part in Rust's favor.

3rd place

This indie platformer is a rare exception when games of this genre, created by small studios on low budgets, become masterpieces.

Most of the games on Unity are created by indie developers (about 90% of the total). Basically, of course, such projects fail or simply go unnoticed by the audience, which hurts Unity's presentability. And only occasionally games like whirlwind among competitors, leaving everyone behind.

Inside is developed by Danish studio Playdead, who are also responsible for the release of Limbo. In Inside, you also play as a nameless boy, traveling through a grotesque and dangerous world.

Here you won't find great gameplay, super-cool graphics, or superbly written dialogues - just an oppressive and dark atmosphere that puts everything on the shelves without words.

In the case of Inside, it will not be possible to discuss any innovative technologies. Unity used , just gave them a wide range of tools and ease of use, which top engines like Frostbite cannot offer.

This was enough for the developers to create the simplest gameplay and graphics, but incredibly touching and memorable game.

2nd place

Another interesting project in Unity is space simulator Kerbal space Program is fascinating , in which you are invited to build your own spaceport, build a rocket and launch it into space!

Many games can offer similar fun, but the Kerbal Space Program is unique in that it requires the player's ingenuity and at least a superficial knowledge of the laws of physics.

It is likely that your first launch in this game will end in failure, and it is no less likely that the same fate will befall the second and even a dozen subsequent ones.

KSP is highly complex, so you will have to consider many factors - the speed required to enter orbit, fuel capacity, gravity, and more - in order to carry out your own space program.

Having dealt with the construction of the rocket, you will try to get into the orbit of the Earth, and then completely leave it in order to get to other planets. In the Kerbal Space Program there are living creatures - kerbals, which will become your astronauts.

Having mastered flights into space, you can choose a more global goal for yourself - to deliver a crew to another planet, disembark it, and then deliver it back.

In general, Kerbal Space Program is a game of enormous difficulty, having overcome which you will get a lot of pleasure and become a little more erudite.

1st place

The Civilization series pioneered the genre 4X strategies. Since the 1990s, she has come a long way and is still considered the best of the best. Naturally, from year to year, the series' emerging financial successes have encouraged and continue to encourage third-party developers to release something similar.

Some work as a carbon copy, a minority do unique games which even surpasses Civilization in many ways. Endless Legend, developed by Amplitude on the Unity engine, is one of those.

Endless Legend came out in 2014. After three years, it has received four major and did not lose that, albeit small, but still a fan base who loved this magical strategy.

And although the goals of the 4X strategy do not differ from many others (you must completely destroy the enemy, or achieve a scientific / territorial / diplomatic victory), its setting and some features stand out significantly from the competitors.

If you are tired of Civilization and similar clones, then pay attention to Endless Legend - a game with its own enchanting universe and unique mechanics, which, most likely, you can fall in love with much more than the "chips" of the same Civilization.

Video: Endless Legend Trailer


Like if you liked it

In the first chapter you will find basic information on downloading and installing Unity and preparing the first scene of our game.

Setting up the environment in Unity

Let's start with the simplest: downloads and Unity settings.

Download the latest version from the official site or torrent and run the installation file.

To edit the code in Unity (4.0.1 and higher), use the MonoDevelop editor. If you are on Windows, you can (and I advise you) to use the Visual Studio 2013 Desktop (C #) alternative editor for Windows, then change the default editor to Visual Studio in Unity settings.

Good to Know: You cannot use the Visual Studio 2013 Express debugger with Unity. You must have Pro version Visual Studio and buy UnityVS plugin. With the Express version, you will have a better code editor, but the lack of a debugger will negate all its advantages.

Mac OS X

A note on the Resources folder: If you've worked with Unity before, you know that Resources is a useful and unique folder. It allows you to load an object or file into a script (using the static Resources class). We will need it at the very end (in the chapter on the menu). Simply put, until we add it.

Our first play scene

Panel Hierarchy(Hierarchy) contains all objects that are available in the scene. This is what you manipulate when you start the game with the "Play" button.

Each scene object is a game object for Unity. You can create an object in the main scene, or in another object in the game. You can also move the object at any time to change its parent.


As you can see here, we have 3 descendants here for the Level object.

V Unity you can create an empty object and use it as a "folder" for other game objects. This will simplify the structure of your scene.

Make sure they all have coordinates (0, 0, 0) so you can easily find them! Empty objects do not use their coordinates in any way, but they do affect the relative coordinates of their children. We won't talk about this topic in this tutorial, let's just zero out the coordinates of the lower empty objects.

Filling the scene

By default, a new scene is created with a Main Camera object. Drag it onto the stage.

First, create these empty objects:

Scripts We will add our scripts here. We use this object to attach scripts that are not associated with the object - for example, a game manager script. Render Our camera and lights will be here. Level

In Level, create 3 empty objects:

  • 0 - Background
  • 1 - Middleground
  • 2 - Foreground

Save the scene in the Scenes folder. Name it whatever you like, for example Stage1. Here's what we got:

Tip: By default, the game object is anchored to the position of the parent. This has an interesting side effect when using a camera object: if the camera is a child object, it will automatically track the position of the parent. If it is the root of the scene or is inside an empty game object, it always displays the same view. However, if you place the camera on a moving game object, it will follow its movements within the scene. V in this case we need a fixed camera, so we put it in an empty Render object. But remember this property of the camera object, it may come in handy. We will elaborate on this topic in the chapter "Parallax Scrolling".

We have just created the basic structure of our game. In the next step, we'll start doing some fun stuff: adding a background to the scene and more!

Add a background to the scene

Our first background will be static. Let's use the following image:


Import the image into the Textures folder. Just copy the file into it, or drag and drop it from the explorer. Don't worry about import settings for now.

Create a new Sprite game object in Unity on stage.

What is a sprite?

Basically, a sprite is a 2D image used in a video game. In this case, it's a Unity object for creating 2D games.

Adding a Sprite Texture

Unity can automatically set the background for your sprite. If none of this happened, or if you want to change the texture, go to the inspector tab and select background: (background)


You have to click on the small round icon to the right of the input field for the Select Sprite to appear in the Inspector

My sprite doesn't appear in the dialog! Make sure you are in the tab Assets the Select Sprite dialog box. If you see the dialog box empty, don't be alarmed. The fact is that for some Unity installations, even with a fresh new 2D project, the images are imported as "Texture" and not "Sprite". To fix this, you need to select the image in the Project panel, and in the Inspector, change the Texture Type property of the Sprite property:

So, we have created a simple sprite to represent the clouds in the sky. Let's make changes to the scene. In the panel Hierarchy(Hierarchy) select New Sprite. Rename it Background1 or something easy to remember. Rename it Background1 or something easy to remember. Then move the object to the desired location: Level -> 0 - Background. Change the coordinates to (0, 0, 0).


Make a copy of the background and place it at (20, 0, 0). This should go well with the first part.

Tip: You can create a copy of the object using cmd + D keys in OS X or ctrl + D Windows.

Sprite Layers

The next statement is obvious, but it has some disadvantages: we are mapping a 2D world. This means that all images are at the same depth, i.e. 0. And you graphics engine doesn't know what to display first. Sprite layers allow us to define what is in front and what is behind.

In Unity, we can change the "Z" of our elements, which will allow us to work with layers. This is what we did in this tutorial before upgrading to Unity 5, but we liked the idea of ​​using sprite layers. Your component has Sprite Renderer there is a field with a name Sorting Layer with default value. If you click on it, you will see:

Let's add some layers to fit our needs (use the + button):

Add a background layer to your background sprite:

Customization Order in layer is a way to constrain sublayers. The lower numbered sprites appear in front of the higher numbered sprites.

Layer Default cannot be deleted as this is the layer used by the 3D elements. You can have 3D objects in a 2D game, in particular, particles are treated as 3D objects by Unity, so they will be rendered on this layer.

Adding background elements

Also known as props... These elements do not affect the gameplay in any way, but they can improve the graphics of the game. Here are some simple flying platform sprites:


As you can see, we have put the two platforms into one file. This good way learn how to crop sprites with new tools Unity.

Getting two sprites from one image

Follow these steps:

  1. Import images into the "Textures" folder
  2. Select the Platform sprite and go to the Inspector panel
  3. Change "Sprite Mode" to "Multiple"
  4. Click on the Sprite Editor button

In a new window (Sprite Editor) you can draw rectangles around each platform to cut the texture into smaller pieces:


The Slice button in the upper left corner will allow you to quickly and automatically do this tedious job:

Unity will find objects inside the image and will cut them automatically. You can set a default value for the pivot point or the minimum size for each slice. For a simple image without artifacts, this is extremely effective. However, if you are using this tool, be careful and check the result to make sure you get what you want.

In this tutorial, we'll do this manually. Name the platforms platform1 and platform2. Now, below the image file, you should see two separate sprites:


Let's add them to the scene. To do this, we will perform the same actions as for the background: create a new sprite and select platform1. Then we will repeat these steps for platform2. Place them in Object 1 - Middleground. Make sure their Z position is zero.


Prefabs


This will create a Prefab that exactly matches the original game object. You will see that the GameObject you converted to Prefab is a new row of buttons right below its name:


A note on the "Prefab" buttons: When modifying the game object later, you can use the "Apply" button to apply these changes to the Prefab, or the "Revert" button to undo all changes to the game object in the Prefab properties. The "Select" button will move the selected properties to the Prefab asset in the project window (they will be highlighted).

Creating prefabs with platform objects will make them easier to reuse. Just drag and drop Prefab to the stage to add a copy. Try adding another platform in the same way.

Now you can add more platforms that change their coordinates, sizes and planes (you can place them in the background or foreground, just set the Z coordinate for the platform to 0).

At this stage, it all looks damp, but in the next two chapters we will add parallax scrolling, and the scene will come to life before our eyes.

Layers

Before moving on, we'll modify our layers to avoid any problems with their display order. To do this, simply change the position of the game objects along the Z axis in the tab Hierarchy(Hierarchy) as follows:

When switching from 2D to 3D mode, you can clearly see the layers in the Scene window:


By clicking on the Main Camera game object, you will see that the Projection checkbox is set to Orthographic. This setting allows the camera to render a 2D game without considering the 3D properties of objects. Keep in mind that even if you are working with 2D objects, Unity still uses its 3D engine to render the scene. The figure above clearly demonstrates this.

In the next lesson:

You just learned how to create a simple static background and how to render it properly. We then taught you how to make simple sprites. In the next chapter, we will learn how to add a player and his enemies.