Unity Setup

What is Unity and how do I install it?

Unity is a game engine, which lets anyone create powerful video games or other real-time 2D or 3D applications. Games which probably most of you have heard of have been developed using Unity. For instance, games like Cuphead, Pokemon GO or Hearthstone: Heroes of Warcraft have been entirely created using Unity game engine.

So if you want to learn the basics of game development, you should follow the steps from here in order to install Unity 😉.

Mainly, you have to install Unity Hub and to create an account.

How to install Unity via Unity Hub

Create Unity account

What is a game engine?

So far you've installed Unity and you've found out that Unity is a game engine. But is more specifically a game engine? As you have probably guessed, Unity is an application which helps us to easily develop computer games or other 2D/3D applications. Instead of focusing on the physics or the mathematics necessary on your game (yes, you need plenty of them in order to create a game), Unity deals in the background with all those complicated things and lets you focus on the logic of your game.

To be more specific, if you want to implement character movement, you have to multiply the character's position with a translation matrix. Without Unity this is how your code would look like (create translation matrix and multiply it with the position):

  1. void Update(float deltaTimeSecoonds)
  2. {
  3. glm::mat4 modelMatrix = glm::Mat4(1);
  4.     modelMatrix = glm::translate(modelMatrix, glm::vec3(translateX, translateY, translateZ));
  5.     RenderMesh(objectToDisplayOnScreen, usedShaders, modelMatrix);
  6. }
  7. void OnInputUpdate(float deltaTime, int mods)
  8. {
  9.     if (window->KeyHold(GLFW_KKEY_W))
  10.     {
  11.         translateX -= speed * deltaTime;
  12.     }
  13. }

Without Unity, you have to write two functions: one which handles events (such us key pressed, mouse key pressed, mouse move) and the update function. For each object in scene you have to specifically save their positions. Then, this coordinates are updated when a specific key is pressed. For instance, if we want to move forward when we press W key, we have to know the axis on which we are moving and it's direction.  With Unity this is how your code looks like:

  1. if (Input.GetKey(KeyCode.W))
  2. {
  3.     transform.Translate(Vector3.forward * speed * Time.deltaTime);
  4. }

Basically, you just write inside the Update function and all you need to know is the direction in which you want to move (forward, left or up). We don't care about axes and their directions. And we don't need to save the separately the coordinates. They are already saved in the object we want to display on screen.

Another example would be gravity implementation. Without Unity you have to write the code by yourself. With Unity, all you have to do is check this checkbox 😋.

How to implement gravity in Unity

What other game engines do exist?

Obviosly, Unity is not the only game engine. There are plenty of them. Here are some other examples:

  • Unreal Engine (Fortnite)
  • CryEngine (first Far Cry games)
  • Anvil (Assassin's Creed)
  • Frostbite (Battlefield, FIFA, Need for Speed)
  • RedEngine (The Witcher)
  • etc.

Why Unity and not Unreal or any other game engine?

So why did we choose Unity for this course and not any other game engine? Well, most of the performant game engines are owned by companies (Frostbite is owned by Electronic Arts, Anvil by Ubisoft). As a result, we do not have access to them. For other good game engines, we have to pay in order to use them. However, Unity and Unreal are free and everyone has access to them.

So why, did we choose Unity and not Unreal? We won't lie, Unreal is way more powerful. You can obtain incredible visual effects with Unreal. But Unreal is more complicated to learn and understand. Usually, every beginner in game development starts with Unity since it is very user friendly. Moreover, there are plenty of examples and documentation for Unity which makes the development process easier than in Unreal.

Do I need anything else besides Unity?

Well, Unity is not enough in order to create a game. You will need an IDE for coding in C#. We suggest Visual Studio.

In the last few classes of this course, you will additionaly need ARCore and Vuforia. But more about this when we get there 😉.

Ultima modificare: Saturday, 24 July 2021, 11:26