Book Image

Unity 3 Game Development HOTSHOT

By : Jate Wittayabundit
Book Image

Unity 3 Game Development HOTSHOT

By: Jate Wittayabundit

Overview of this book

<p>Unity 3d is the game engine of choice for creating professional looking games at no cost. Its combination of powerful tools and outstanding community support make it the natural choice for experienced and aspiring game developers. <br /><br />Unity3D Game Development Hotshot will show you how to exploit the full array of Unity3Dtechnology in order to create an advanced gaming experience for the user. It has eight exciting and challenging projects with step- by-step explanations, diagrams, screenshots, and downloadable materials.<br /><br />Every project is designed to push your Unity skills to the very limits and beyond. You will create a hero/heroine for a role playing game. Create a menu for the RPG game allowing you to customize your character with powerups, armor, and weapons. You will shade, model, rig, and animate your hero/heroine. The end result will be a&nbsp; character on the level of Final Fantasy, far superior to a simple sprite.<br /><br />Now for some damage - rocket launchers! Typically the most powerful weapons in any first person shooter, you will create a rocket launcher that has fire and smoke particles and most importantly causes splash damage for that all important area effect. Create AI controlled enemies for your hero/heroine to eliminate with the rocket launcher. Forge&nbsp; a destructible&nbsp; interactive world so if the rocket launchers miss their target they will at least cause significant damage to the surrounding environment. Learn to save and load your game so you can take a break from the action for life’s necessities like going to the bathroom. Incorporate social gaming by uploading scores online so everyone can see the carnage.</p>
Table of Contents (19 chapters)
Unity 3 Game Development HOTSHT
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Only Unity fits the bill of being a game engine that allows you to create a full 3D game for free, and with phenomenal community support. This book will equip you with the skills to create professional looking games at no cost.

Unity 3 Game Development Hotshot will teach you how to exploit the full array of Unity 3D's technology in order to create an advanced gaming experience for the user, with eight exciting and challenging projects that provide a step-by-step explanation, diagrams, and screenshots to help you achieve that goal.

Every project is designed to push your Unity skills to the very limits and beyond. You will create a hero/heroine will be used in an RPG game. You will create a menu for the RPG game allowing you to customize your character with powerups, armor, and weapons. You will shade, model, rig, and animate your hero/heroine, so that they start to look more like a character from Final Fantasy than a simple sprite.

Now for some damage—rocket launchers! Typically the most powerful weapon in any first-person shooter, you will create a rocket launcher that has fire and smoke particles and most importantly causes splash damage for that all-important area effect. You will create AI-controlled enemies for your hero/heroine to eliminate the rocket launcher. We will create an interactive world that is destructible, so if the rocket launchers miss their target they will damage the surrounding environment. Finally, you learn to save and load so you can take a break from the action for life's necessities like going to the bathroom. The final touch will be for you to upload your scores online so everyone can see the carnage.

What this book covers

Project 1, Develop a Sprite and Platform Game: This project will show the user how to create a sprite animation for a 2D platform game. There will be an explanation of the difference between a perspective and orthographic camera, how to set up a background camera and the character camera, how to create a 2D sprite from your texture (using mainTexture and mainTextureOffset function in Unity), how to set up a sprite sheet, as well as the jumping and gravity animations.

Project 2, Create a Menu for an RPG Game- Add Powerups, Weapons, and Armor: This project will use the first project to create a cool and complex UI that is mostly used in the RPG game. The project starts by creating the menu window with OnGUI(), which will include the tab button for the user to go to different menus, and be able to manage the items, change the armor or weapon for the character, and choose the items and skills.

Project 3, Model and Shade your Hero/Heroine: We will start by exporting the 3D character model from 3D Studio MAX with the right unit scale and rotation by using the FBX exporter from 3D Studio Max and import it to Unity. Then, we will write a custom shader by using the new surface shader, which will be available from version 3.0.

Project 4, Add Character Control and Animation to your Hero/Heroine: Beginning with setting up the walk, run, idle, jump, and fall animations, we will adapt the built-in third-person controller in Unity to create a custom third-person controller. We will also use the character controller, cross fade animation, and the camera to follow our character.

Project 5, Build a Rocket Launcher!: In this project, we will create a first-person controller similar to the Resident Evil Style with the character animation. We will create a rocket launcher, rocket, and the particle effect by using the prefab and instantiate function to clone the object.

Project 6, Create Smart AI: This project will continue from the last project, and we will create an AI enemy and make it smart enough to follow our character, shoot at us, and follow the way point. We will also use the Gizmo class to help us show the direction of the AI.

Project 7, Forge a Destructible and Interactive Virtual World: We will use the new unity built-in beast lightmap to create a lightmap to make the world more realistic. Then, we will create the Physics object in the scene that will react with our character by walking through it or shooting at it.

Project 8, Let the World See the Carnage! Save, Load, and Post High Scores: This project will show you how to load, save, and post your high score by using playerPref. We will also learn to make the web game load faster and not let the user wait too long by using streaming when we publish from Unity.

Appendix A, Important Functions: This appendix includes the details of some important functions such as, Awake(), Start(), and so on, sourced from Unity scripting reference.

Appendix B, Coroutines and Yield: This appendix includes the explanation of Coroutines/Yield and how to use them, sourced from Unity scripting reference.

Appendix C, Major Differences between C# and Unity JavaScript: This appendix shows the differences between C# and Unity JavaScript by using examples sourced from the Unity answer website and Unity scripting reference.

Appendix D, Shaders and Cg/HLSL Programming: This appendix explains the structure of the Shaders and Cg/HLSL language, basic function in CG/HLSL, and so on, sourced from Unity scripting reference and NVIDIA website.

What you need for this book

You will need Unity 3.x that you can download from http://www.unity3d.com/download/ and 3D Studio Max (Optional), which can be downloaded from http://usa.autodesk.com/3ds-max/trial/.

Who this book is for

This book is for users who already have some basic knowledge of how to use the Unity game engine and intermediate users who want to explore Unity above and beyond the basic techniques.

Conventions

In this book, you will find several headings appearing frequently.

To give clear instructions of how to complete a procedure or task, we use:

Mission briefing

This section explains what you will build, with a screenshot of the completed project.

Why Is It Awesome?

This section explains why the project is cool, unique, exciting, and interesting. It describes what advantage the project will give you.

Your Hotshot Objectives

This section explains the major tasks required to complete your project.

  • Task 1

  • Task 2

  • Task 3

  • Task 4, and so on

Mission Checklist

This section explains any pre-requisites for the project, such as resources or libraries that need to be downloaded, and so on.

Task 1

This section explains the task that you will perform.

Prepare for Lift Off

This section explains any preliminary work that you may need to do before beginning work on the task.

Engage Thrusters

This section lists the steps required in order to complete the task.

Objective Complete - Mini Debriefing

This section explains how the steps performed in the previous section allow us to complete the task. This section is mandatory.

Classified Intel

The extra information in this section is relevant to the task.

You will also find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: " We can change the Tiling by calling the material.mainTextureScale function to set the X tile and Y tile."

A block of code is set as follows:

public var f_speed : float = 5.0;
public var loopSprites : SpriteManager[];
private var in_direction : int;

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

if (hit.collider.tag == "Key") {
    if (!b_hasKey) {
      //We hit our Key
      audio.volume = 1.0;
      audio.PlayOneShot(getKeySound);
      b_hasKey = true;
      Destroy (hit.gameObject);
    }
  }

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Click on the Continue button to break the prefab."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you a PDF file that has color images of the screenshots used in

this book. The color images will help you better understand the changes in the

output. You can download this file from https://www.packtpub.com/sites/default/files/Images.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.