Textbook Getting Started With Unity 2018 A Beginner S Guide To 2D and 3D Game Development With Unity 3Rd Edition Edward Lavieri Ebook All Chapter PDF
Textbook Getting Started With Unity 2018 A Beginner S Guide To 2D and 3D Game Development With Unity 3Rd Edition Edward Lavieri Ebook All Chapter PDF
Textbook Getting Started With Unity 2018 A Beginner S Guide To 2D and 3D Game Development With Unity 3Rd Edition Edward Lavieri Ebook All Chapter PDF
https://textbookfull.com/product/mastering-ui-development-with-
unity-an-in-depth-guide-to-developing-engaging-user-interfaces-
with-unity-5-unity-2017-and-unity-2018-1st-edition-ashley-
godbold/
https://textbookfull.com/product/developing-2d-games-with-unity-
independent-game-programming-with-c-1st-edition-jared-halpern/
https://textbookfull.com/product/developing-2d-games-with-unity-
independent-game-programming-with-c-1st-edition-jared-halpern-2/
https://textbookfull.com/product/learning-c-programming-with-
unity-3d-alex-okita/
https://textbookfull.com/product/sams-teach-yourself-
unity-2018-game-development-in-24-hours-3rd-edition-mike-geig/
https://textbookfull.com/product/learn-unity-for-android-game-
development-a-guide-to-game-design-development-and-marketing-1st-
edition-adam-sinicki/
Getting Started with Unity 2018
Third Edition
BIRMINGHAM - MUMBAI
Getting Started with Unity 2018
Third Edition
Copyright © 2018 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form
or by any means, without the prior written permission of the publisher, except in the case of brief quotations
embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented.
However, the information contained in this book is sold without warranty, either express or implied. Neither the
author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to
have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products
mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy
of this information.
ISBN 978-1-78883-010-2
www.packtpub.com
To Veronica Brentwood for being an inspiration
Mapt is an online digital library that gives you full access to over 5,000 books and videos, as
well as industry leading tools to help you plan your personal development and advance
your career. For more information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical eBooks and Videos
from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
PacktPub.com
Did you know that Packt offers eBook versions of every book published, with PDF and
ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a
print book customer, you are entitled to a discount on the eBook copy. Get in touch with us
at [email protected] for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a
range of free newsletters, and receive exclusive discounts and offers on Packt books and
eBooks.
Contributors
Thank you to Packt Publishing for your continual support and belief in me. There are so
many great people at Packt that I worked with on this project, including, Larissa, Yusuf,
the reviewers, technical editors, proofreaders, the indexer, and the marketing team. It is a
pleasure to have worked with such an amazing team.
About the reviewers
Andreas Oehlke is a professional full-stack software engineer. He holds a bachelor's degree
in computer science and loves to experiment with software and hardware. His trademark
has always been his enthusiasm and affinity for electronics and computers. His hobbies
include game development, building embedded systems, sports, and making music. He
currently works full-time as a senior software engineer for a German financial institution.
He has also worked as a consultant and game developer in San Francisco, CA. He is also the
author of the book Learning LibGDX Game Development.
Ludovico Cellentani is a senior engine programmer at King AB, and he has been working
as a professional game programmer for almost 20 years. During this time, he has worked on
a number of games released on various platforms, spanning PC, consoles, and mobile.
[ ii ]
Table of Contents
Heads-Up Display 72
The difficulty balance 74
Difficulty balance questions 74
Implementation plan 76
Project organization 77
Custom assets 78
Standard assets 80
Organization 80
Summary 81
Chapter 4: Creating Our Terrain 82
Creating the terrain 82
Working with height maps 83
Importing the terrain 83
Shaping the terrain 85
Smoothing our terrain 85
Creating our spawn points 87
Painting the terrain 89
Adding water 91
Saving your work 94
Adding vegetation 94
Summary 99
Chapter 5: Lights, Cameras, and Shadows 100
Working with cameras 101
Understanding camera projections 104
Orientating your frustum 104
Creating a Skybox 105
Using multiple cameras 107
Working with lighting 108
Directional lighting 109
Point lighting 110
Spot lighting 111
Area lighting 112
Implementing reflection probes 113
Understanding shadows 115
[ iii ]
Table of Contents
Summary 116
Chapter 6: Creating and Importing 3D Objects for Our Game 117
Understanding assets and GameObjects 118
Asset packages 119
Understanding GameObjects 120
Creating 3D objects in Unity 122
Using prefabs 124
Using additional 3D objects 126
Using the Unity Asset Store 126
Hands-on with the Unity Asset Store 128
Incorporating custom assets in our game 129
Working with imported assets 131
Planting Cherry Trees 132
Planting Cucumber Patches 135
Summary 138
Chapter 7: Implementing Our Player Character 139
Working with Unity's standard asset package 140
Importing the game character 142
Configuring a player controller 143
Fine-tuning our character 146
Fine-tuning the motor controls 146
Fine-tuning scale 149
Fine-tuning the Capsule Collider 151
Changing and refining input controls 152
Animating our player character 155
Reviewing the player controller script 155
Reviewing the Animator component 158
Previewing the animations 161
Terraforming the terrain for our Cucumber Man 162
Summary 162
Chapter 8: Implementing Our Non-Player Characters 163
Understanding the non-player characters 164
Importing the non-player characters into our game 165
Animating our non-player characters 166
[ iv ]
Table of Contents
[v]
Table of Contents
[ vi ]
Table of Contents
[ vii ]
Table of Contents
Index 310
[ viii ]
Preface
With the pervasiveness of games and the use of gamification in nearly every industry, the
desire to discover how to use state-of-the-art development software has never been so great.
There is an increasing number of software tools available to help developers create amazing
games for consoles, the web, desktop computers, and mobile devices. Game engines are
among the most powerful of these tools available. The Unity 3D game engine is one of the
elite game engines. It has been used to create popular 2D and 3D games by large game
studios and indie developers. With a free version available, and the newest release of Unity,
the time has never been better to start using Unity.
Getting Started with Unity 2018, Third Edition covers one of the most popular game engines
available. This book will guide you through the entire process of creating a 3D game, from
downloading the Unity game engine to publishing your game. You will enjoy the coverage
of some exciting topics in this book, including player-controlled characters and animation.
Whether you are just getting started as a game developer or have experience with Unity or
other game engines, this book will provide you with a guided tour of developing games
with Unity 2018. With clear explanations, tips, and ample screenshots, you will be provided
with detailed steps to develop your game.
This book takes a practice hands-on approach to learning Unity 2018. As you progress
through each chapter, you will build a 3D interactive game called Cucumber Beetle. As you
create the game, you'll learn the key features of Unity 2018, including creating a game
environment, animating characters, scripting, and more. All meshes, models, textures,
animations, and other assets are available on the book's website.
By the time you complete the lessons in this book, you'll have the confidence to start using
Unity 2018 to create your own games.
Chapter 2, The Unity Interface, examines Unity's primary views, windows, layouts, and the
toolbar. The interface components covered in this chapter are the ones used most often.
Chapter 3, Designing the Game, covers the design of the book's featured game—Cucumber
Beetle. The game design includes gameplay, game mechanics, the player character, the non-
player characters, game assets, animations, and more. Screen mock-ups and narratives
are used to document the game's design.
Chapter 4, Creating Our Terrain, features the creation and customization of game terrain.
Shaping tools are introduced, and water and vegetation features are added to the game
environment.
Chapter 5, Lights, Cameras, and Shadows, explores cameras and lighting in Unity. The
chapter starts with a look at cameras to include perspectives, frustums, and Skyboxes. The
use of multiple cameras to include mini-maps is covered. Different types of lighting,
reflection probes, and shadows are also explored.
Chapter 6, Creating and Importing 3D Objects for Our Game, focuses on making the game
environment more robust, and trees and other objects are added to the game scene. This
chapter also examines the steps necessary to create 3D objects using Unity's native
modeling tools. Assets are added to the game from the Unity Asset Store and from 3D
assets prepared specifically for the Cucumber Beetle game.
Chapter 7, Implementing Our Player Character, incorporates the game's player character—the
Cucumber Man. The character is imported, and the controls and animations are reviewed.
By the end of the chapter, the game will be ready for testing in the game mode.
[2]
Preface
Chapter 9, Adding a Heads-Up Display, covers the design and development of, and how to
incorporate, a Heads-Up Display (HUD) in the game. A canvas is used to create text and
graphics that provide visual indicators of points, health, and additional information to help
the player maintain situational awareness during game play. A mini-map is also
implemented.
Chapter 10, Scripting Our Points System, looks at the design, scripting, and implementation
of the game's point system. This includes providing frame-by-frame updates to key
onscreen components of the game's HUD.
Chapter 11, Scripting Victory and Defeat, dives into the design and scripting of the game's
victory and defeat conditions. Scripts will be updated to manage the Cucumber Man's
health, provide frame-by-frame onscreen updates, and ensure that a player life is lost when
the health runs out. Character lives and respawning are also covered.
Chapter 12, Adding Audio and Visual Effects to Our Game, demonstrates the plan
and implementation of audio and visual effects in the game to help enhance overall game
play. Specifically, audio is added to the key events in the combat system and several special
effects, using Unity's particle system, are added to the game.
Chapter 13, Optimizing Our Game for Deployment, discusses optimization and deployment.
The steps required to diagnose Unity games for performance problems are explored, in
addition to how to optimize scripts and graphic rendering. The Unity build process is
explained along with how to create a standalone player and how to deploy games for
multiple platforms.
Chapter 14, Virtual Reality, examines Unity's capabilities with regard to virtual reality. An
introduction to Virtual Reality is provided, including the hardware requirements. you will
learn how to create a Virtual Reality game using the Unity game engine.
The only software requirement is downloading and installing the Unity game engine. Those
steps are detailed in the book, so no software is required before you start reading.
[3]
Preface
Once the file is downloaded, please make sure that you unzip or extract the folder using the
latest version of:
The code bundle for the book is also hosted on GitHub at https://github.com/
PacktPublishing/Getting-Started-with-Unity-2018-Third-Edition. In case there's an
update to the code, it will be updated on existing GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at
https://github.com/PacktPublishing/. Check them out!
Conventions used
There are a number of text conventions used throughout this book.
[4]
Preface
CodeInText: Indicates code words in text, database table names, folder names, filenames,
file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an
example: "Ensure the Skybox folder is selected in the Project panel"
Bold: Indicates a new term, an important word, or words that you see onscreen. For
example, words in menus or dialog boxes appear in the text like this. Here is an example:
"Select Fill option from the HUD_canvas."
Get in touch
Feedback from our readers is always welcome.
General feedback: Email [email protected] and mention the book title in the
subject of your message. If you have questions about any aspect of this book, please email
us at [email protected].
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you have found a mistake in this book, we would be grateful if you would
report this to us. Please visit www.packtpub.com/submit-errata, selecting your book,
clicking on the Errata Submission Form link, and entering the details.
Piracy: If you come across any illegal copies of our works in any form on the Internet, we
would be grateful if you would provide us with the location address or website name.
Please contact us at [email protected] with a link to the material.
[5]
Preface
If you are interested in becoming an author: If there is a topic that you have expertise in
and you are interested in either writing or contributing to a book, please visit
authors.packtpub.com.
Reviews
Please leave a review. Once you have read and used this book, why not leave a review on
the site that you purchased it from? Potential readers can then see and use your unbiased
opinion to make purchase decisions, we at Packt can understand what you think about our
products, and our authors can see your feedback on their book. Thank you!
[6]
Downloading and Installing
1
Unity
In this chapter, you will learn about game engines and look at four different types before
focusing on Unity. Once that foundation is set, we will start taking a deep look at Unity's
beginnings, where the game engine is today, and how it has progressed to being one of the
top game engines in use today. We will highlight Unity's capabilities and features. We will
then review the system requirements for developing Unity as well as running, Unity games.
Finally, we will download and install Unity.
The basic concept of game engines is that they provide a powerful set of tools to handle
much of the grunt work of game development, allowing developers to focus on game
aesthetics and gameplay. In the early days of video games, each game was coded from
scratch without a game engine's libraries or capabilities. Instead of reinventing the wheel
for each game, game engines started to emerge, making it easier for game studios to churn
out games.
Game engines are not general-purpose software suites that can create any game imaginable.
They are highly specialized and, although very flexible, are intended for a specific range of
game genres. For example, the Ego Game Technology Engine by Codemasters is used
primarily for creating racing games; Pyrogenesis, by Wildfire Games, is used for creating
real-time-strategy (RTS) games; the Silent Storm Engine, by Nival Interactive, is used
predominately for turn-base tactics games; and ONScripter, by Naomi Takahashi, is used
for creating visual novels and first-person adventure games.
[8]
Downloading and Installing Unity Chapter 1
When deciding on which game engine to use for a given game project, consider the typical
characterization of games in the primary genre that your game is a part of.
We use the phrase primary genre because many modern games blur the
genre lines and incorporate characteristics of two or more genres. This
genre blurring can result in new and innovative games.
Battlefield
Bioshock
Borderlands
Call of Duty
Destiny
Doom
HalfLife
Halo
Left4Dead
Overwatch
Rainbow Six
[9]
Downloading and Installing Unity Chapter 1
FPS games are created with the intent of immersing the player in the game world. They are
playing as a character and, to obtain the desired level of immersion, animations, audio, and
graphics quality are critically important. Special attention is given to the character's arms
and weapons:
Third-person games
Third-person games are games where the player character is nearly or completely visible in
the game scene. This genre includes third-person shooters (TPS) and third-person
action/adventure. That means that a considerable effort needs to be focused on a character's
appearance and animations. These games are based on the third-person character
perspective as illustrated here:
[ 10 ]
Downloading and Installing Unity Chapter 1
Here are some of the more successful and popular third-person games:
Dead Space
Gears of War
Grand Theft Auto
Prince of Persia
Rainbow Six
Resident Evil
SOCOM
Splinter Cell
Uncharted
These games are typically characterized by the following, in addition to the characteristics
listed in the previous section for FPS games:
[ 11 ]
Downloading and Installing Unity Chapter 1
Because the Unity game engine is featured later in this chapter and used
throughout this book, it is not covered in this section.
CryENGINE
CryENGINE is developed by Crytek. Interestingly, this game engine was initially created to
produce a game demo for Nvidia, a graphics processing unit (GPU) manufacturer and
because of that demo's great success, the game (Far Cry) was taken into full production and
is now a commercial success. The game engine itself is also very successful.
The engine is freely available along with the full source code. There are no financial
obligations for commercial use of CryENGINE such as royalties. This engine is capable of
high-quality visuals and excellent performance, and you can develop games for the
following platforms:
Linux PC
Oculus Rift
Playstation 4
Windows PC
Xbox One
[ 12 ]
Downloading and Installing Unity Chapter 1
Lumberyard
Lumberyard is part of the Amazon Web Services (AWS) platform and, at the time of this
book's publication, is still in beta. This is a free AAA game engine based on CryENGINE.
Lumberyard's unique selling point is that no other game engine offers deep integration with
Amazon Web Services and Twitch.
With this engine, you can develop for the following platforms:
Android
HTC Vive
iOS
Oculus Rift
OSVR
PC
PlayStation 4
PlayStation VR
Xbox One
For further information on AWS Lumberyard, I recommend Learning AWS Lumberyard Game
Development by Packt Publishing: https://www.packtpub.com/game-development/
learning-aws-lumberyard-game-development.
[ 13 ]
Downloading and Installing Unity Chapter 1
Windows PC
Windows Phone
Xbox 360
For further information on XNA, I recommend Microsoft XNA 4.0 Game Development
Cookbook by Packt Publishing: https://www.packtpub.com/game-development/microsoft-
xna-40-game-development-cookbook.
Unreal comes with several templates that make getting started very easy. These are:
2D File Scroller
First Person
Flying
Puzzle
Rolling
Side Scroller
Third Person
Top Down
Twin Stick Shooter
Vehicle
Vehicle Advanced
Android
Daydream
HTML 5
iOS
Linux
[ 14 ]
Another random document with
no related content on Scribd:
The Project Gutenberg eBook of Angel Esquire
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.
Language: English
Angel Esquire
By EDGAR WALLACE
Angel Esquire, of Scotland Yard, has his hands full in
helping Jimmy Stannard, as he is known to the criminal
element of London, solve the puzzle of the great safe
which held the fortune of Old Reale who had placed it
there, and who had taken the precaution to hide the
combination in a bit of doggerel verse that served as a
cryptogram.
When Old Reale’s Will was read it was found that four
people might benefit by it. Two of them, known as
members of the famous “Borough Lots” gang would stop
at nothing to gain possession of the fortune. Jimmy and
his friend are pitted against them in a story that constitutes
the finest entertainment for the person liking excitement,
love and mystery combined.
OTHER BOOKS
BY THIS AUTHOR:
THE BLACK ABBOT
THE CLUE OF THE NEW PIN
THE DOOR WITH SEVEN LOCKS
THE MELODY OF DEATH
A KING BY NIGHT
THE RINGER
THE SINISTER MAN
THE TERRIBLE PEOPLE
TERROR KEEP
TRAITOR’S GATE
A. L. BURT COMPANY
Publishers · New York
See Reverse Side of Jacket for Complete
List of 75c Fiction
ANGEL ESQUIRE
By EDGAR WALLACE
Author of
“The Girl from Scotland Yard,” “The Traitors’ Gate,”
“The Clue of the New Pin,” “The Green Archer,”
“The Hairy Arm,” “Blue Hand,” “The Black
Abbott,” “The Sinister Man,” “Terror
Keep,” “The Ringer,” “The Door with
Seven Locks,” “A King by Night,”
“The Melody of Death,” “The
Four Just Men,” “Jack
O’Judgment,” etc.
A. L. BURT COMPANY
Publishers New York
Printed in U. S. A.
Copyright, 1908,
BY
HENRY HOLT AND COMPANY
Copyright, 1927,
BY
SMALL, MAYNARD & COMPANY
(Incorporated)