At this point, you’ve accomplished your goal of having all the main actors ready, but it’s essentially an empty stage. Sure, you might win some avant-garde awards for a poignant play on the lack of free will, but that’s not going to pay the bills.
In this chapter, you’ll add some interactivity to your game through the use of components, which are fundamental to Unity game development. If you were to think of a GameObject as a noun, then a component would be a verb, or the part that performs the action; a component does something on behalf of a GameObject.
You can also think of them as Lego bricks. You can create these elaborate GameObjects by combining various components.
Note: This tutorial is part of a collection that teaches Unity development from the ground up. You can read the entire series over here. This series is free and does not require any account creation. All assets are provided. If you find it useful, feel free to buy me a coffee.
You’ve learned a bit about components already. In previous chapters, you learned how each GameObject has one required component: The Transform component, which stores the GameObject’s position, rotation and scale.

But Unity comes with far more components than that. For instance, there’s a light component that will illuminate anything near it. There’s an audio source component that will produce sound. There’s even a particle system component that will generate some impressive visual effects. And, of course, if there isn’t a component that does what you want, you can write your own.
In this chapter, you’ll learn about several types of components, including the Rigidbody component, the script component, and more. By the end of this chapter, your marine will be running and gunning!
You can download the starter project for this chapter here: https://drive.google.com/file/d/1JDj-dkW5lM_tvoYHWe07Gb6upCD9wkEc/view?usp=drive_link
Getting started with components
If you completed the last chapter, open your current Bobblehead Wars project to pick up where you left off. If you got stuck or skipped ahead, open the Bobblehead Wars starter project from this chapter’s resources.
Currently, the space marine only knows how to stand like a statue. He needs to move around if he’s going to avoid being some alien’s snack.
The first thing you’ll add is a Rigidbody component, which opts the GameObject into the physics engine. By adding it, you’ll enable the GameObject to collide with other GameObjects.
You’ll learn much more about Rigidbodies and collisions when you reach the Chapter 4, “Physics.” For now, just take it at face value and move forward.
Adding a component
In the Hierarchy, select the SpaceMarine GameObject and click the Add Component button in the Inspector.

You’ll see many different categories. When you know which component you need, simply search by name. Otherwise, select one of the categories and pick the best option.

Click the Physics category, then select Rigidbody.

You’ll see that a Rigidbody component was attached to the GameObject. Congratulations! You’ve added your first component.

Each component has its own set of properties, values and so forth. These properties can be changed in the Inspector or in code. Components also have their own icons to make it easy to determine their type at a glance.

You’ll notice some icons in the top right-hand corner of each component, like this:

The first icon is the Reference icon. Click it. It’ll open another window with the documentation page for that component. If you installed the documentation, this page is on your computer — and, yes, the search bar works.

The second icon is the presets button. As you customize your components, you may prefer a certain, preset, configuration created previously.
Configuring the Rigidbody
This Rigidbody component informs Unity that the current GameObject is ‘opting-into’ the Unity physics system. This means the GameObject can collide with other GameObjects and be affected by gravity and other external forces.
The Rigidbody also provides numerous other options. In the Rigidbody component, first check the IsKinematic checkbox.
By checking Is Kinematic, you are informing Unity that you will be manually moving the GameObject as opposed to reacting to external forces. Manually moving a GameObject gives you precise control over it. This is good for character movement, but it will not respond to collisions. Your GameObject will be informed of a collision event, but it’s up to you to determine how it behaves.
Next, uncheck the Use Gravity option. When characters respond to gravity, those characters will fall through the world until they encounter a collider. Since there are no colliders in the game, the characters will fall forever (which is a long time).
Here is the configured Rigidbody component:

You’ll learn more about Rigidbodies in Chapter Four, “Physics”.
Saving presets
All components have other configuration options. One such aspect is called presets. You can save your component configurations as a preset, then switch to it as needed. You can also create new GameObjects with those assigned presets, saving you time. Click the Preset button to save your current Rigidbody configuration.

Clicking this button opens the preset menu. Click the Create New Rigidbody Preset option. Remember, if you are having trouble seeing the options, you can adjust the size of the presets with the slider and options at the bottom.

From the save menu, give it the name Kinematic and save it in the Presets folder. If you select the Kinematic option in the Presets folder, you’ll see your properties.

Should you need it again, you can select it from the Presets menu and it will populate the Rigidbody component.
Other component options
Components also have other features. At the top of your Rigidbody component on the right-hand side, click the three vertical buttons.

You’ll see a bunch of options.
- Reset will reset the component to its default values.
- Move to Front and Move to Back adjust the ordering of sprites in 2D games.
- Remove Component will delete the component from the GameObject — you can undo this action.
- Move Up and Move Down adjusts the component ordering in the Inspector.
- Copy Component allows you to copy a component from one GameObject and paste it onto another.
- Paste Component as New will paste a copied component to a GameObject.
- Paste Component Values allows you to overwrite the values of the current component from a copied component. Specifically, you can copy the values of a component while your game is being played. When you stop the game, you can paste those values onto another component. This is quite useful because sometimes it’s useful to tweak things as you play to see what works in practice.
- Find References in Scene will show just the GameObjects with similar components. Everything else is greyed out. Try it out. You’ll see your Space Marine. To return to a normal Scene view, clear out the Search bar in the Hierarchy.
Now you are cooking with components.
Where to go from here
Components provide a rich assortment of functionality for your GameObjects. Unity provides a ton of them, but Unity allows you to write your own. This comes in the form of C# scripting. You’ll get started adding your first script in the next tutorial.
Discover more from Jezner Blog
Subscribe to get the latest posts sent to your email.