Unity Building Blocks

A Unity project is made up of four main things:

  1. Scenes
  2. GameObjects
  3. Components
  4. Assets

Click on each for an introduction to each part, and read on to learn about how they all relate to each other.

It’s useful to understand the hierarchy here. A project is a collection of scenes, and scenes are collections of GameObjects. Each GameObject has a number of Components attached to it, and components utilize Assets.

Scenes

A scene is a three dimensional environment. It’s a Cartesian coordinate System, 3D or 2D, depending on the game.

GameObjects

A GameObject is anything in the game. For an object to be in the game, it needs to be in the scene, and thus it has some location in space. The object might just be something that plays background music – it doesn’t always need to be visible, it will still technically exist in the scene somewhere. These sorts of “management” objects that one would think of as existing outside of the scene are, in Unity, just part of the scene. If you can’t see them and they don’t take up space for the physics system, then who cares?

Every GameObject has at least one component: The Transform component. The transform component stores the information of where they object is in 3D space. Because every object exists in the scene, they need the Transform component. You can’t delete it.

Components

A component is, in most cases, a behavior. Adding them to a GameObject makes the GameObject do something. You could add a Sprite Renderer component to a 2D project to make the gameObject appear in the scene as an image. Light components will create various types of light sources, and Camera components give the player a perspective with which to view the game from.

In order to see the 2 or 3 dimensional space full of stuff, we need a camera. A camera does what it does in real life. From a single point, it takes what is visible in front of it and projects it onto a 2 dimensional rectangle: the computer screen when we play the game. We could put the camera where the main player would be for a First Person game, behind some 3D model of the player for third-person games, or just leave it sticking out in space. Frankly, we can do whatever the hell we want with the camera. Sometimes I like attaching it to unexpected objects.

Once I was making a golf game, and I didn’t have a model of a golf club. I quickly put a camera on the end of an “invisible” stick (I rotated it around a point), and when you swung to hit the ball, it was like hitting the ball with your face. Later I put the camera “inside” the ball, and you got to fly around. I forgot to lock the camera from rotating, so when you hit the ball the entire world turned into a nauseating spinning mess. The gold ball object and the camera object are, in this case, the same. One gameObject with multiple components.

Almost every game will need a camera. If there is only one camera component in the scene, then Unity will automatically use that camera to display content to the player. This is useful, we don’t often need to “set” a main camera. (TIP: if you wan to do fancy camera stuff, go install cinemachine).

In the Scene view, we are looking at the scene, so we have a “camera” but that’s just part of the editor. There is the camera that is attached to a GameObject (“Main Camera” by default when you create a scene).

Assets

Finally, we have assets. Assets are files on our hard drive that the game uses. Things like images, 3D models, sounds, and so on. Without assets, out game wouldn’t be very much. Just lots of ‘primitives’ (like cubes or spheres). They are stored in an Assets folder, accessed through the project window, and referenced by components.