Objective: Create a script to guide our missile to the nearest enemy.

Welcome to the first part of this series. In this article, we are going to create some requirements for the functionality of our homing missile. So let's get started.


OBJECTIVE: Remove the color from an animated shield sprite sheet so we can assign a color from a C# script

The first step is to copy the sprites to a new directory.


Objective: Write C# code to control the left and right side thruster animations.

In part two of this series, we added thruster animations to our spaceship, the main thruster on the rear of the spaceship, and two side thrusters. The main thruster on the rear of the spaceship is always active. The two side thrusters are active only when the ship is turning. To do this we will have to write a few lines of code to our “Player” C# script.


Objective: Add thruster animations to our main engine and side thrusters for left and right movement.

In part one we added some C# code to allow us to move our space up, down, left, and right. Now we need to add some animations to provide the thruster visual effects.

Thruster sprite sheet

Next, we create an animation.


Objective: Increase “Player Speed when the “Left Shift” key is held down.

To make this magic is the use of the “Input.GetKey” function call. If we use the “Input.GetKeyDown” we only get a TRUE condition for a very brief moment after the key is pressed. “Input.GetKey” stays TRUE as long as we hold the key down.

While holding down the “Left Shift” key we change the value of “_speed” from 4 to 8.


The “Player” game object

Objective: Add movement to our spaceship or what we will refer to as our “Player” game object.


Objective: Provide functionality to quit a Unity application using the “Escape” (Esc) key.

This is a simple task to complete thanks to the “Application.Quit( )” function. Place the above code in a “void Update( )” function body as shown below and you are finished.


Sharing an early version of your game on the web can be a quick way to get feedback from family and friends. The process of creating a “Web GL” build will allow you to do just that.


Ok, you worked hard on putting your game together and now you want to be able to create a “Build” or generate the file(s) needed to run the game outside of the Unity editor. This can be a simple task for a small game. So let's “build” our game.

To get started click on “Build Settings”.


Objective: Play a sound clip with a C# script

Create an “Empty Game Object” and call it “Audio_Manager”. Use Add Component” to add the “Audio Source” component. Create a C# script and name it “ Play Laser Sound”. Add the C# script to the “Audio Manager” game object (“Drag and Drop” on to the “Audio_Manager”).

Open the “ Play Laser Sound” C# script and create a private Serialized Field variable of type AudioClip and call it “_laserSoundClip”.

Create a second private variable of type “AudioSource” and call it “_audioSource

Bradley Yachimowski

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store