Unity Lab #3 GameObject Instances

C# is an object-oriented language, and since these Head First C# Unity Labs are all about getting practice writing C# code, it makes sense that these labs will focus on creating objects.

You’ve been creating objects in C# since you learned about the new keyword in Chapter 3. In this Unity Lab, you’ll create instances of a Unity GameObject and use them in a complete, working game. This is a great starting point for writing Unity games in C#.

The goal of the next two Unity Labs is to create a simple game using the familiar billiard ball from the last lab. In this lab, you’ll build on what you learned about C# objects and instances to start building the game. You’ll use a prefab—Unity’s tool for creating instances of GameObjects—to create lots of instances of a GameObject, and you’ll use scripts to make your GameObjects fly around your game’s 3D space.

Let’s build a game in Unity!

Unity is all about building games. So in the next two Unity Labs, you’ll use what you’ve learned about C# to build a simple game. Here’s the game that you’re going to create:

So let’s get started. The first thing you’ll do is get your Unity project set up. This time we’ll keep the files a little more organized, so you’ll create separate folders for your materials and scripts—and one more folder for prefabs (which you’ll learn about later in the lab):

  1. Before you begin, ...

Get Head First C#, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.