If you haven’t read part 1, here a quick link to it:
Last time we went through the “Interactive tutorial”, this time I will talk about the “Roll-a-ball” tutorial.
The “Roll-a-ball” tutorial is first basic tutorial after the “Interactive tutorial”. I followed the video tutorial in the Unity website and it provides step-by-step instructions which make it very easy even if you know nothing about Unity. I started from scratch and ended up with a Roll-a-ball game constructed by basic shapes. The game is simple, you control the rolling ball and collects the gems to gain points.
Creating basic 3D shapes is easy in Unity. It took me very little time to learn the geometry system in Unity and created the stage area with stretched cubes, the ball and the gems.
Things start to get a little bit more interesting. We need to enable the player to move the ball. Unity is designed to be modular and each object in the game has its own list of components. To enable the ball movement, we need to create a component in the ball which maps the arrow keys to apply forces to the ball in different directions. Such component is not provided in Unity, instead I need to create a script in C# which contains just a few lines.
// At the start of the game..
void Start ()
// Assign the Rigidbody component to our private rb variable
rb = GetComponent<Rigidbody>();
// Set the count to zero
count = 0;
// Run the SetCountText function to update the UI (see below)
winText.text = "";
// Each physics step..
void FixedUpdate ()
// Set some local float variables equal to the value of our
// Horizontal and Vertical Inputs
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
// Create a Vector3 variable, and assign X and Z to feature
// our horizontal and vertical float variables above
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
// Add a physical force to our Player rigidbody using our 'movement'
// Vector3 above,
// multiplying it by 'speed' - our public player speed that
// appears in the inspector
rb.AddForce (movement * speed);
The gems are also animated using the script so they are spinning slowly and become a bit more attractive. I also added the collider component for the gems. When the gems are collided by the ball, it will trigger a function in the script, which makes the gem disappear and adds one point to the score.
The “Roll-a-ball” tutorial is only about 1 hour long. After that, you can already start expanding the game by designing new levels if you want. The ball cannot fall from the ground in the tutorial since the playing area is fenced by stretched cube, but I can imagine they can be removed to make it a little more difficult and fun. There’s a game with a similar concept which you have to control the ball from point A to point B without falling off the cliff. I haven’t played it before and I don’t know the name. But I’ve watched it on Youtube and it looks kind of fun to me.
Again, Unity did a very good job to introduce itself to the community. It doesn’t matter how great your game engine is until you have great support for the beginners or potential users. Same applies to programming languages, APIs and basically every tool that has a steep learning curve.