Today is our Unity Night, where we learn about, well, Unity! For those who don’t know, Unity is a popular free to use game engine, and it is also our game engine of choice for our development. Because of this, all departments will need to be familiar with Unity to contribute to development, so that is what today is all about. But first…
On Sunday at 5pm, we’re watching the Isle of Dogs on Discord!
Submissions close TONIGHT at 11:00pm!
Taco Cat Tasks
Task signups for our mock studio game Taco Cat are open! Go ahead and start signing up for tasks on the GitHub Projects page for the game.
Game Objects, Components, and Scenes
These three terms are very important in understanding how Unity works. A Game Object is any object in your game. This can include the player, the background elements, enemies, and even objects that aren’t visible. These objects exist in Scenes, which serve as the game world. A given game can have many scenes to represent different parts of the game (different levels, title screen, minigame sections, etc.). All Game Objects have Components. Components are what give any Game Object the ability to do things. For example, a Game Object may have a Collider component to allow it collide with other Game Objects. We often will make our own components through the use of C# Scripts. Developing these C# Script Components is at the core of what the Programming Department does. Game Objects can also have sub Game Objects inside of them. We call these Child Game Objects. For example, an enemy Game Object might have a child Game Object that represents the weapon the enemy is holding. These children can, in themselves, have child game objects too. As a summary, the Scene is the game world which contains Game Objects which themselves have Components that dictate what a Game Object can do. To see how these three things manifest in development, let’s take a look at Unity’s layout.
Unity’s Default Layout
Upon opening a Unity project, you’ll see a layout that looks something like this
There’s a lot going on here so let’s take a look at all the different parts.
At the left of the screen (the purple section) we have the Hierarchy. This is where you can find all of the game objects in your scene. At the bottom is the project view (the green section), where we can see all of the files in our Unity project. The center has the viewport which allows us to view our scene, and the inspector on the right (the blue section) allows to look at game object in more detail. Knowing this, let’s take a look at the scene again in detail.
By clicking on “My_Cool_Cube” in the Hierarchy, we see two things happen. First, the cube itself gets highlighted in the Scene. Second, the Inspector starts showing all the cube’s details. In the inspector, you’ll see various names with drop downs next to them like the Transform and the Box Collider. These are examples of components. The box collider is a type of collider that is cubic shaped. The Transform manages a Game Object’s position, rotation, and scale (size). We also see the Mesh Filter and the Mesh Renderer, both of which are used to make the cube model show up on the screen. You’ll also notice an Add Component button at the bottom. Clicking that box opens a text search where you can search for an add more components to the Game Object. Note: You can select a game object either by clicking on its name in the hierarchy or clicking on the actual object in the scene.
Saving Game Objects
Often times a game will use several of the same Game Object. For example, all the levels in a game may use the same player or there may be several of the same enemy throughout the level. There are also may be situations where we’ll need to spawn game objects on the fly mid game. In situations like this, it can be very useful to save Game Objects as files so we can reuse them and reference them later. In Unity, these saved game objects are called Prefabs (think Pre-Fabricated, meaning a Pre-Made game object). You can see by looking at the Asset portion of our Unity Editor (which has all our game files) that we’ve already turned our “My_Cool_Cube” Game Object into a prefab file. This can be done by dragging the game object from the Scene or Hierarchy into the Assets. To use the prefab, simply drag it back from Assets to the Viewport.
Our Typical Workflow
Our typical work cycle revolves around all of these features. First we make Game Objects and position them to where we want them to be in the Scene. Next we attach/create components to/for our Game Objects until they are able to do what we need them to do. Then, we repeat the process for all the Game Objects needed for our game.
Since all departments will use Unity, it is highly recommended that you all have Unity ready to go! We’ll be using version 2021.3.16f1. So, even if you already have Unity installed, make sure you install this version! Developing the same project on different versions of Unity will cause problems! Here’s a guide on how to install and use Unity Hub to install different version of Unity.
Anyway, that’s it for this week! Feel free to check out the meeting slides for more info! The slides contain videos showing off some of the features described here, so I recommend looking at those!