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: 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.

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.

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…

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