10. Game #3: The Break-Up Part 2 – Unity 3.x Game Development by Example

Chapter 10. Game #3: The Break-Up Part 2

When last we left our put-upon protagonist, he had been kicked out of his apartment by his girlfriend, who began throwing lit bombs at him from the fourth floor. Luckily, our hero is bizarrely invulnerable to bombs, and what's more, he can defy the laws of physics by balancing them on his nose. Clearly, we've got some work ahead of us if we want this game to make any sense.

As we continue to round out The Break-Up, we'll add the beer steins and their smash animations. We'll write a collision detection script to make the character react when he catches things. We'll learn how to save time by using one script for two different objects. Then we'll add some sound effects to the game, and we'll figure out how to throw a random number to play different sounds for the same action. Let's get gaming.

Time for action – Amass some glass

If the whole point of the game is to catch mugs from the character's precious beer steins of the world collection, then adding the steins should be our next step.

  1. Create a new Prefab. Remember, you can either right-click in the Project panel and choose Create | Prefab, or you can create one through the menu by clicking on Assets | Create | Prefab.

  2. Name the new Prefab as Stein. Drop it into your Prefabs folder.

  3. Locate the Stein model in the Models folder of the Project panel.

  4. Click-and-drag the Stein model into the empty Stein Prefab container. As we saw before, the icon should light up blue to indicate that the Prefab has something in it.

Time for action – Creating a Particle System

We've learned these steps before no surprises here. Now let's review how to create a Particle System so that we can get a shattering glass effect for when our steins hit the pavement:

  1. Go to GameObject | Create Other | Particle System in the menu.

  2. Rename the new Particle System Glass Smash.

  3. Hover the cursor over the Scene view and press the F key to focus the camera on your Particle System. You may have to orbit the camera if the apartment building gets in the way (hold down the Alt key and click/drag to do this).

  4. In the Inspector panel, use the following settings (keep all other settings at their default):

    In the Ellipsoid Particle Emitter section:

    • Min Size: 0.2

    • Max Size: 0.2

    • Min Energy: 0.05

    • Max Energy: 3

    • Min Emission: 50

    • Max Emission: 100

    • World Velocity Y: 20

    • Rnd Velocity: 10 for all values

    • One shot: Checked

  • In the Particle Animator section:

    • Does Animate Color?: Unchecked. We'll just keep our particles white, so there is no need to put an extra color-animating burden on Unity.

    • Force Y: -50

    • Autodestruct: Checked

  • In the Particle Renderer section:

    • Cast Shadows: Unchecked

    • Receive Shadows: Unchecked

What just happened getting smashed

After punching in these settings, you should see a reasonable approximation of a shatter. We get this splash effect by sending the particles up in the Y-axis with our World Velocity setting. The particles are then pulled back to Earth with a Force of -50 in the Y-axis, which we set in the Particle Animator section. Particles go up, particles come down. (Note: you won't see this effect if you're in the top isometric view. Rotate your Scene into a Perspective view to see what's happening.)

Time for action – Making it edgier!

The particles look a bit like snowflakes at the moment. We want something more like sharp glass fragments, so let's set up a new Material with a sharper-edged texture on it to make this effect look more convincing.

  1. In the Project panel, right-click an empty area and choose Create | Material.

  2. Name the Material as Glass.

  3. In the Inspector panel, choose Particles | Additive in the Shader dropdown.

  4. Click on the Select button in the texture swatch, and choose glassShard.png from the list. (This image is in the assetsPackage file for Chapter 10.)

  5. Select the Glass Smash Particle System from the Hierarchy panel.

  6. In the Inspector panel, scroll down to the Particle Renderer component.

  7. In the Materials section, choose the Glass material from the pop-up menu.

What just happened I fall to pieces

Once we swap in these harder-edged textures, the effect is much improved! Now our Glass Smash Particle System looks a little more like an explosion of glass chunks than a violent headshot to Frosty the Snowman.

Time for action – Containing the explosion

Let's place this Glass Smash Particle System into a Prefab so that it's ready to use with our falling beer steins.

  1. In the Project panel, right-click and choose Create | Prefab.

  2. Rename the new Prefab as Glass Smash.

  3. Click-and-drag the Glass Smash Particle System from the Hierarchy panel into the empty Glass Smash Prefab. The icon lights up blue. That's how you know it's working.

  4. With the Particle System tucked safely away into the Prefab, delete the Glass.

  5. Smash Particle System from the Scene (select it in the Hierarchy panel, and press the Delete key on your keyboard, or Command + Delete if you're using a Mac).

Note

Clean up

I've kept my Project panel neat and tidy by putting all of my Prefabs into a folder. I've done the same thing with my scripts, my materials, my models, and my dirty sweat socks. Because there's not a lot going on in this project, it may seem like wasted effort. Still, organizing assets into folders is a good habit to get into. It can save your sanity on larger projects.

What just happened duped?

We've almost duplicated the same process we followed to get the bomb working. Have you noticed? With both the bomb and the stein, we put an imported model into a prefab, and we created a particle system and put it in its own prefab. Then we created a script to move the bomb down the screen. We attached that script to the bomb. Then we dragged the bomb's explosion particle system into the prefab variable of its Script component.

This is all starting to sound familiar: too familiar. In fact, remember when we said earlier that programmers are always finding ways to do less work? We saw that if you type the same line of code twice, you may not be writing your code to be as maintenance-friendly as possible. The same holds true for this bomb/beer mug situation. If the bomb and the beer mug both need to do the exact same thing, why don't we use the same script for both?

Time for action – Let's get lazy

There's no need to create an entirely separate script for the stein. Follow these steps to get more bang for your buck out of a single script:

  1. Find the script you called Bomb Script in the Project panel, and rename it FallingObjectScript. Because we'll be using the script more generically, we should give it a more generic name.

  2. In the Project panel, select the Stein Prefab (not the Stein Model).

  3. Choose Component | Scripts | FallingObjectScript in the menu to attach the script to the Prefab.

  4. In the Inspector panel, you should see that the FallingObjectScript has been added as a Script component to the Stein Prefab.

  5. As we did earlier with the Bomb Prefab, find the Glass Smash Prefab in the Project panel. Click-and-drag it into the prefab variable. By doing this, you're telling the Script which thing you want to add to the screen when the stein falls on the ground. In the bomb's case, it's the explosion. In the stein's case, it's the glass smash.

  6. Add a Capsule Collider component to the beer stein.

  7. Click to select the Cylinder child inside the Stein (click the grey arrow to expand the child list to see it). Change the Cylinder's X/Y/Z position values to 0.

  8. Jump back up to the parent Stein node. Change the parameters of its capsule collider:

    Radius: 2

    Height: 5.5

  9. Add a Rigidbody component to the beer stein.

  10. Remember to uncheck Use Gravity in the Rigidbody component settings. We're handling the beer stein's movement programmatically.

Two birds, one stone; or rather, two objects, one script! To test out the beer stein, drag the Beer Stein Prefab into your Scene, then click on the Play button.

What just happened FallingObject: The PuppetMaster

Just like the bomb, the beer stein plummets from a random X position at the top of the screen and explodes in a shower of particles when it hits the "ground". The bomb explodes and the glass smashes, but both are controlled by an identical script. Unfortunately, they both come to a gentle stop on top of the character's face when they collide, but that's what we'll take a look at next.

Very variable?

You may already be sending up warning flags about this madcap plan to use one script for two different objects. What if we wanted the bomb to travel at a different speed than the beer stein? And don't we want two completely different reactions depending on whether the player collides with the bomb or the stein?

We'll answer the collision question a little later in the chapter, and we'll tackle the variable speed question now. But before we do, fire up your gray matter. How would you solve this problem? How would you make the objects move at two different speeds, with two different collision reactions, and still use the same script?

Terminal velocity is a myth bombs fall faster

Ignoring the laws of physics for a second, let's look at how to make the two objects fall at different speeds using the same script. One solution is to declare a variable called speed at the top of the FallingObjectScript.

var speed:int;

Change this line:

transform.position.y -= 50 * Time.deltaTime;

to:

transform.position.y -= speed * Time.deltaTime;

Then for each object, input a different number for the speed value in the Inspector panel. Try 30 for the stein and 50 for the bomb. Two objects, one script, and two different speeds. Awesome? Confirmed: awesome.

Note

Know when to double down

At some point, objects become different enough that sharing a script is no longer saving you time and effort, it's causing you grief. As a game developer, you need to decide what sort of structure best suits your game-creating goal. Programmers have all kinds of tricks to save themselves work and to logically structure their code. The object-oriented programming pillar called inheritance (which we've looked at briefly) is another way to get two objects to share code, while ensuring that they function as two different things.

Note

Wait till Sunday to take your code to church

When it comes down to just getting your game finished and playable, don't ever feel foolish about making mistakes and writing your game the "wrong" way. A great rule, especially when you're starting out, is to get the game working first, and then go back to make the code elegant. TOTALLY A FACT: tuning up your code and making it as organized and pretty as possible is called refactoring. When you're just starting out, worry more about functional code than elegant code.

What just happened when Game Objects collide?

Bombs plummet from the top floor of the apartment building and explode around our character, as his beloved beer steins shatter on the pavement with every step he takes. These are the origins of a competent catch game! Now, let's worry about what happens when the player catches a stein or comes in contact with a bomb.

There are a few different ways we can go about this. We can write the collision detection code into the FallingObjectScript, but that might get complicated. We're using the same script for both objects, and the objects need to do different things when they hit the player. It makes more sense to me to put the collision detection on the player character. We'll check to see when he gets hit by something, and then based on what hits him, he'll react in different ways.

Time for action – Tagging the objects

As we saw before with our bouncing heart, we can tag objects in the Scene, and then refer to objects in code using their tag names. Let's tag the bomb and the stein so that the player character can tell what hit him.

  1. Select the Bomb Prefab in the Project panel. (You can actually select anything in this step. We're not actually applying a tag just creating one. But we need to select something so that we see the Tag interface in the Inspector panel. You can also reach it by clicking Edit | Project Settings | Tags in the Unity menu.)

  2. At the top of the Inspector panel, press and hold on the dropdown labeled Tag, and select Add Tag....

  3. Click on the gray arrow to expand the Tags list near the top of the Tag Manager.

  4. Click in the blank area to the Element 0 label, and type the tag name bomb.

  5. Then punch in a tag called stein.

  6. Select the Bomb Prefab again in the Project panel. (This is where it counts.)

  7. In the Inspector panel, choose your new bomb tag from the drop-down list labeled Tag.

  8. Follow the same process to tag the Stein Prefab.

With the bomb and stein properly tagged, we can write our collision detection code.

Time for action – Writing the collision detection code

Pop open the Character Script and let's get bizzay.

Type up the following function within the script. Be sure to follow the rules we've learned about where to properly write a new function (that is, "outside" of your other functions):

function OnCollisionEnter(col : Collision)
{

  if(col.gameObject.tag == "bomb")
  {
     // I got hit by a bomb!      
  } 
  else if (col.gameObject.tag == "stein")
  {
    animation.Play("catch"); // Ima catch that stein!
  }
  col.gameObject.transform.position.y = 50;
  col.gameObject.transform.position.y = -16;
  col.gameObject.transform.position.x = Random.Range(0,60);
}

Once again, our prior knowledge of useful game code serves us well. This line should already look familiar:

function OnCollisionEnter(col : Collision) {

We're declaring a function in this case, a special built-in Unity function called OnCollisionEnter and accepting a variable called col as an argument. The value of col is a collision that Unity's physics calculations detect whenever rigid bodies smack into each other.

if(col.gameObject.tag == "bomb")

col.gameObject refers to whatever thing hits the Game Object to which this script is attached (the Character). gameObject.tag, naturally, refers to whatever tag that Game Object has stuck to it. We stuck bomb and stein tags on the Bomb Prefab and Stein Prefab, so that's what we should get. We use a branching conditional (if) statement to react to either the bomb or the stein.

animation.Play("catch"); // Ima catch that stein!

If the player gets hit by a beer stein, we'll play the "catch" animation stored in the Character model.

col.gameObject.transform.position.y = 50;
col.gameObject.transform.position.z = -16;
col.gameObject.transform.position.x = Random.Range(0,60);

No matter what hits the player, we're going to throw it back up to the top of the screen at some random X position and let it fall back down. This becomes problematic if we end up having other stuff hit the player that doesn't need to respawn at the top of the building, but let's get it working simply, for the time being.

But wait! Ees problem, señor. Save the script and try the game out. Then see if you can spot the problem.

Time for action – Animation interrupts

The trouble is that we're telling the character to play his "catch" animation, but it's not happening. We see, at best, the first frame of that animation, and then it's interrupted by either the "idle" or "step" animation.

Luckily, we can add a condition to the script to prevent these glory-hog animations from playing if we're trying to catch a beer stein. Dip back into your CharacterScript and make these changes:

 if(lastX != transform.position.x) {
   if(!isMoving) {
     isMoving = true;
     if(!animation.IsPlaying("catch")){
        animation.Play("step");
     }
   }
 } 
 else {
   if(isMoving) {
      isMoving = false;
      if(!animation.IsPlaying("catch")) {
         animation.Play("idle");
      }
   }
 }

By wrapping the animation.Play calls in these animation.isPlaying conditionals, we can ensure that the character isn't busy playing his catch animation when we determine it's time to step or idle. Remember that!

Save the script and try it out. Your player character should start catching those steins like a champ!

What just happened the impenetrable stare

The magical properties of our character's iron-clad bomb-catching face continue to amaze: now, the bombs hit the character straight in the schnozz and wondrously disappear! I don't know how many cartoons you watch, but last time I saw someone get hit in the face with a bomb, there was a satisfying explosion, along with (possibly) a snickering mouse nearby.

How convenient. We just happen to have a reusable Prefab that contains a satisfying bomb explosion. Wouldn't it be great if we could trigger that explosion to happen right on top of the character's face? (The character might disagree with us, but I say let's go for it!)

Time for action – Adding facial explosions

Just as we did when our falling object hit the ground, we'll use the Instantiate command to make a copy of a Prefab appear in the game world. This time around, when we determine that the player has been hit in the face by a bomb, we'll instantiate the Explosion Prefab on top of his head.

  1. Add the following line to the top of the code:

    var lastX:float;
    var isMoving:boolean = false;
    var explosion:GameObject;
    
  2. Later on, in the conditional statement that determines when the player is hit by a bomb, add the Instantiate command:

    if(col.gameObject.tag == "bomb")
    {
      // I got hit by a bomb!      
      Instantiate(explosion, col.gameObject.transform.position, 
      Quaternion.identity);
    }
     else if (col.gameObject.tag == "stein") {
    
  3. Save and close the Script.

  4. In the Project panel, select the Character Prefab.

  5. In the Inspector panel, locate the Explosion variable in the Script component.

  6. Click-and-drag the ExplosionPrefab into the Explosion variable slot.

What just happened raindrops keep 'sploding on my head

We already know how the Instantiate command works, so we won't dissect it again. When the bomb drops on the player's head, it appears to explode. The explosion removes itself when it's finished, because the Particle System is set to autodestruct. Of course, we know what's really going on: we're just moving the bomb to the top of the building and setting it to some random position along the X-axis so that the player thinks it's a new bomb. Meanwhile, we're instantiating a new copy of the ExplosionPrefab at the exact spot where the bomb was when it collided with the player. Sneaky!

Time for action – Making some noise

So far, the games we've made have been completely silent. I count this as a terrible tragedy; audio in a game can account for half of the player's emotional experience. In the case of games like Rock Band, there would be no game without audio (hilarious little plastic instruments notwithstanding). Audio is so important to games that even crummy little low-rent sound effects (like the ones we're about to add to this game!) can increase the game's awesomeness by a factor of WOW... to the power of GEE GOLLY something like that. It's all very scientific.

Let's rig up our Bomb and Stein Prefabs so that they can emit sounds.

  1. In the Project panel, click on the Bomb Prefab.

  2. In the menu, click on Component | Audio | Audio Source to add the Audio Source component.

  3. Repeat those steps to add an Audio Source component to your Stein Prefab.

Note

Now hear this

You may have noticed that Unity also offers an Audio Listener component. What's the deal? Well, in the case of a 3D game, you don't necessarily want the player to hear everything that's going on all the time. You want him to hear audio fading in and out as he moves closer to or farther from the source (the Audio Source, to be specific). By default, an Audio Listener component is attached to the Main Camera in any Scene. In something like a first-person perspective game, the Audio Listener will only pick up sounds from Audio Source-enabled Game Objects if it's within range. If we tweak the settings just right, the player won't hear a noisy washing machine GameObject from the other side of the level. Each scene can only have one Audio Listener at a time.

Unity also offers a Unity Reverb Zone component. This is a spherical gizmo that lets you define an area where the sound is "pure" and unaffected, with a candy-coated craziness shell around it that lets you define echoes and other potentially oddball effects.

With the Bomb and Stein Prefabs so enabled, we can add a few lines to the FallingObjectScript to make them play sounds when they hit the ground.

Time for action – Adding sounds to the FallingObjectScript

Let's drop a couple of lines into the FallingObjectScript to fire off a few sounds:

  1. Open the FallingObjectScript.

  2. Declare a clip1 variable at the top of the script:

    var prefab:GameObject;
    var speed:int;
    var clip1:AudioClip;
    
  3. Just after we determine that the falling object has hit the ground, play the clip1 sound:

      if(transform.position.y < 0)
      {
         audio.PlayOneShot(clip1);
    

By now, you've probably guessed that there's one more step involved. The script really has no idea what a clip1 actually is it's just a variable placeholder. Let's add some actual sound files to the Bomb and Stein prefabs to get this party started:

  1. In the Project panel, click to open the SFX folder. Yay sounds!!

  2. Again in the Project panel, click to select the BombPrefab.

  3. In the Inspector panel, locate the clip1 variable in the FallingObjectScript component.

  4. Click-and-drag the sound effect labeled explosion1 into the clip1 variable slot.

  5. Repeat the previous steps for the Stein Prefab, but this time, choose the smash1 sound effect.

Test your game. Whenever the bomb hits the dirt, there's a satisfying (if retro) sound effect to accompany it. Likewise, there's an 8-bit approximation of glass smashing whenever the beer stein shatters.

What's the catch?

Using the same method that you used earlier, you should be able to figure out how to add that "catch" sound effect to the player character when he catches a beer stein. Likewise, you want to enable the explosion1 sound effect if the player gets hit by a bomb. If you can't figure it out on your own, take a deep breath, and then go nag someone else to figure it out for you. That's called delegating, and it's a perfectly legit way to develop a game.

Note

Perfect for smashing

Unity has all kinds of complex sound controls for playing music and other effects, but like the One Shot setting for Particle Systems, the audio.PlayOneShot command is perfect for collision sound effects. If you'd like to learn more about adding sounds and music to your game, look up AudioSource class, AudioListener class, and AudioClip class in the Unity Script Reference.

Note

Low-fi, high fun

The sound effects that we're using for our game were created with a freeware sound effects generator called SFXR. The sounds are all free to use and adorable, hearkening back to a time when dragons looked like ducks and heroes had big white 4-pixel squares for heads. Download a copy of SFXR to generate your own temporary (or even final) game audio. Look for a download link for SFXR and loads of other helpful resources in the appendix at the back of this book.

Have a go hero Sound off

If you're not a big fan of the retro sounds, it's possible that you may have missed out on the cavalcade of cheese we now know as the 1980s. Feel free to create and import your own sound effects for the game. There are a few different ways you can go about this:

  • Get bizzay with a microphone and record your own effects. This is the only way you can truly be happy with the results and get exactly what's in your head into the game. The industry term for sound effect scores is called "foley". You could use the method acting approach and actually smash glass and detonate high-powered explosives next to your computer (not recommended), or you could say "boom!" and "smash!" into the microphone. It's a style thing.

  • There are a number of companies that sell royalty-free sound effects for film, television, and movies. I'll give you two warnings about using these: the first is that royalty-free sound effect collections can be very expensive on a hobbyists' budget. The second is that once you get enough experience with these popular collections under your belt, movies and teevee shows will be forever ruined for you. You'll hear these same sound effects everywhere! It's tough to stay immersed in a tense film when all you're thinking is "Hey, that's track #58 from disc 2 of the Explosive Ballistics Collection."

    There are less expensive royalty-free sound effect websites online, but I've found that a good number of them contain pirated sound effects from the pricy collections that are passed off as legit effects. Caveat emptor, which is Latin for "You probably won't get sued, but do the right thing anyway."

Time for action – Mixing it up a bit

One of my personal beefs about sound design in games is when the sound effects are too samey. In our game, hearing the same two sound effects over and over again is wearying. One of the things I like to do is to create a bunch of slightly different sound effects for the same event, and when the time comes to play a sound, I just choose one of them at random. This can really vary the soundscape of the game and keep your player from overdosing on the same sound effects.

You probably noticed that the SFX folder contained five versions of the smash and explosion sound effects. Let's learn how to set them up to play randomly:

  1. Open the FallingObjectScript.

  2. Delete the line where you define the clip1 variable, and replace it with an array declaration:

    var prefab:GameObject;
    var audioClips : AudioClip[];
    
  3. Modify the line where you play the sound:

    audio.PlayOneShot(audioClips[Random.Range(0,audioClips.length)]);
    
  4. Let's take a closer look at this new code:

    var audioClips : AudioClip[];
    

This is a special built-in array; it is statically typed, which means we're telling Unity what kind of thing it's going to contain. In this case, it's going to be a list of AudioClip types. A normal array (var myArray = new Array()) won't show up in the Inspector panel, but a built-in array will.

audio.PlayOneShot(audioClips[Random.Range(0,audioClips.length)]);

What we're doing here is picking a random number from 0 to the built-in array's length. We're using the resulting number as the index of the audioClip in the array that we want to play.

The last step is to click-and-drag the explosion and smash sound effects into the new built-in array in the Inspector panel:

  1. Select the Bomb Prefab in the Project panel.

  2. In the Inspector panel, locate the FallingObjectScript component.

  3. Click to expand the AudioClips array.

  4. Enter a value of 5 in the Size label. The list expands even further to accommodate five empty slots for AudioClip objects.

  5. Click-and-drag the five explosion sound effects into the various indices of the array.

  6. Repeat these steps for the Stein Prefab using the smash sound effects.

  7. Run the game.

Now the falling objects make different-ish noises when they hit the ground. Variety is the spice of life. Paprika is also reasonably delicious.

Have a go hero Filling in the gaps

Consider this the jumping-off point for your catch game. With the basics roughed in, there are a number of finer elements missing from the experience:

  • Title screen with Play button

  • Instructions page

  • Credits screen

  • Endgame

  • Play Again button

  • Onscreen scoring (counting the number of steins the player has collected)

We already know how to do a lot of this stuff. We've built a Title screen with a Play button for Robot Repair, and it's the same process to build in the other screens, like Credits and Instructions. We've created an onscreen counter for Ticker Taker. We've built a timer for use in our games as well.

If you imagine all of these elements as ingredients in a cake, you should know how to bake a pretty scrumptious dessert by now. There are a few different decisions you can make about how the game plays:

Score points

Let the player catch beer steins. Count up each one he catches. End the game when he gets hit by a bomb. Show the player his last and best scores, and add a message when he beats his best score, exactly as we did with the Ticker Taker.

Survive

Add a timer to the screen. The player has to keep collecting beer steins until the timer runs out. He's allowed to miss only three beer steins if he drops his third stein, or gets hit by a bomb, the game ends. This is different from the last scenario because there's a definite win scenario, whereas the other method kept the player playing until he inevitably lost. This win scenario doesn't lend itself as well to adding a high score board, and it doesn't have as much replay value. But certain players (myself included) just can't get excited about games they can't win.

Quota

Clocks are a great and frequently used gameplay tool, but sometimes they just give players the jitters. Another way you can determine a player's success is by defining a quota: "You must catch x beer steins to finish the game."

Levels

One possibility that a "win" scenario opens up is a multi-level structure for your game. If the player makes it through the first level, you increase the number of bombs (or the falling speed of the objects). Maybe a bus periodically drives through the screen, and the player has to jump down a manhole to avoid it? Maybe the mugs get smaller and harder to catch, or the bombs get larger and harder to avoid? If you are using a timer for a survival mode, increase the length of time the player has to spend to survive. If you're using a quota system, increase the number of steins the player has to catch to finish the level.

In this way, you combine the best of both worlds: the game has finite successes because the player can finish and feel accomplished. But the player is also guaranteed to lose because the quota keeps getting larger and more impossible to fill. You could even loop it right back around and put a level cap on the game; after finishing level 10, the player wins once and for all. Perhaps his high score is the lowest time it took him to complete all ten levels?

Health points

You could create some Legend of Zelda-style heart graphics and display them at the top-right of the screen. Every time the player gets hit by a bomb, remove a heart. If the player loses all his health, the game ends. This feature works with both the "score points" and "survive" ideas, and helps to give the player much more of a fighting chance. The player is usually more willing to play your game if he perceives that the rules are "fair" and if he can own any mistakes he makes. He should never feel like the game "made him die". Keep in mind that "fair" can sometimes mean "unfairly advantageous to the player" as long as the computer doesn't "cheat", it's fair in the player's eyes.

Catch unlit bombs

You could create another bomb Prefab that doesn't have the sparking fuse, and ask that the player catch both beer steins AND unlit bombs. The objects would probably need to fall more slowly, and you may need to increase the size of the fuse sparks to help the player differentiate a lit bomb from an unlit one. Better yet, to make it even more "fair", you could put a bright red texture on the lit bombs.

Vary the landscape

Doesn't this guy have anything in his apartment other than cartoon bombs and Oktoberfest souvenirs? In order to make the game more visually interesting, you could import a few new models and chuck those out the window. Tighty whities and naughty magazines might make nice additions to the fiction.

Summary

The savings don't stop there! We've already been able to take a scant knowledge of programming and a few simple Unity concepts and turn them into three capable beginner games, with a lot of potential. In the next chapter, we'll actually milk even more mileage out of our blossoming game development skills by applying a graphics re-skin to The Break-Up to turn it into a completely different game! Join us, won't you?