Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Title Page
Copyright and Credits
Unity 2017 Game Development Essentials Third Edition
Dedication
Packt Upsell
Why subscribe?
PacktPub.com
Contributors
About the author
About the reviewers
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Conventions used
Get in touch
Reviews
Entering the Third Dimension
Getting to grips with 3D
Coordinates
Local space versus world space
Vectors
Cameras
Projection mode – 3D versus 2D
Polygons, edges, vertices, and meshes
Shaders, materials, and textures
Rigidbody physics
Collision detection
Softbody physics
The Cloth component
Getting to grips with 2D in 3D
Ignoring one axis
Understanding Sprites
Essential Unity concepts
The Unity way – an example
Assets
Scenes
GameObjects
Components
Scripts
Prefabs
The interface
The Scene view and Hierarchy view
Control tools
Scene navigation
Control bar
Create button
The Inspector
The Project window
The Game view
Summary
Prototyping and Scripting Basics
Your first Unity project
A basic prototyping environment
Setting the scene
Adding simple lighting
Another brick in the wall
Building the master brick
Creating our first prefab
And snap! It's a row
Grouping and duplicating with empty objects
Build it up, knock it down!
Introducing C# scripting
A new behavior script or class
What's inside a new C# Monobehaviour class
Base Monobehaviour methods
Variables in C#
Comments
Write the Shooter class
Declaring public variables
Assigning scripts to objects
Moving the camera
Local, private, and public variables
Understanding Translate
Implementing Translate
Testing the game so far
Making a projectile
Creating the projectile prefab
Creating and applying a material
Adding physics with a Rigidbody
Saving prefabs
Firing the projectile
Using Instantiate() to spawn objects
Adding a force to the Rigidbody
Resetting the wall to initial state and clearing the projectiles
Summary
Creating and Setting Game Assets
Setting up the scene and preparing game assets
Placing the prefabs in the game
Importing and placing background layers
Implementing parallax scrolling
Making it last forever
Using the Asset Store
The FreeParallax component
Understanding and setting up elements
Playing in the middleground
Avoiding holes and discrepancies on the ground collider
Putting in the foreground and special layers
Creating a death zone
Spawning collectable items
2D animation basics
Importing animated Sprites
The Animator component
Animator state-machine editor
Transitions between animation states
Conditions and parameters
Final words
Summary
Player Controller and Further Scripting
Working with the Inspector
Tags
Layers
Prefabs and the Inspector
Scripting with Unity
Statements
Variables
Variable data types
Using variables
Public and private variables
Declaring variables
Full code example
Functions
Update()
OnMouseDown()
Writing custom functions
Return type
Arguments
Declaring a custom function
Calling a custom function
If else statements
Multiple conditions
For loops
Inter-script communication and Dot Syntax
Accessing other objects
Find() and FindWithTag()
SendMessage
GetComponent
Programming for mobile
Dot Syntax
Null reference exceptions
Coroutines
Comments
Further reading
Anatomy of a 2D character
Extending the Platformer2DUserControl class
Making the player and writing the game logic
Analyzing, understanding, and modifying the component's source code
Defining a namespace
Spawning collectible items
Adding a timer
Making things difficult with health and obstacles
Layer Collision Matrix
Making it look and sound better
Adding a simple shadow for the character
Inserting audio: environmental sfx, background music, sound events
Sprite shading with real-time lights
Writing some additional game logic
Homework
Summary
Character Animation with Unity
Unity Legacy Animation System
Importing character models and animations
Importing animations using multiple model files
Setting up the animation
Building the Player with Animator
What is an avatar in Unity?
Configuring an avatar
Fixing issues with the default bone mapping
Configuring muscle actions and settings
Importing animation clips for Animator
Setting up animations to ensure correct looping
Scaling the model
Understanding Animator
Animator component
Animator component properties
Animator controller
The Animator window
Animator state machine
Understanding the state machine
Controlling a character's behavior with state machines
Animation states
What's the Any State state?
Our first Blend Tree state
Conclusions
Controlling Animator through code with parameters
Root-motion animations
Using a better approach – Root motion
Animation transitions
Setting the transitions between states
Blend Trees
Modifying Unity standard assets classes to implement our playing character
Adding the final touches
Cloth simulation – giving life to hero's hair and skirt
Inverse Kinematics
Summary
Creating the Environment
Designing the game
Understanding and using the Terrain tool
Setting terrain features
Setting the terrain size detail and resolution
Importing and exporting 2D heightmaps
The terrain tool
Terrain component
Raise height
Paint Height
Flatten Heightmap
Smooth Height
Paint Texture
Place Trees
Refresh (tree prototypes)
Edit Trees
Mass placement of trees
Paint details
Refresh (detail prototypes)
Edit details
Terrain Settings
Creating the island
Step 1 – Setting up the terrain
Step 2 – Creating the island outline
Step 3 – A small lake carving
Step 4 – Adding textures
Painting procedure
Sandy areas
Adding grass and rock
Step 5 – Tree time
Step 6: The grass is always greener
Step 7 – Let there be light!
Creating sunlight
Procedural skybox
Step 8 – Surrounding the island with sea water
A small lake
Step 9: What's that sound?
Positional audio versus non-positional audio
Audio file formats
The hills are alive!
Importing the book's asset package
Further audio settings
Enabling positional 3D sound and setting up curves
Step 10 – Walkabout
Step 11: Final tweaks
Summary
Interactions, Collisions, and Pathfinding
Digital content creation applications
Common import settings for models
Model
Materials
Animation
Wrap Mode
Animation Compression
Setting up the hut model
Adding the model
Positioning the model
Manually adding the colliders
Physic Material
Adding audio
Collisions and triggers overview
Ray casting
Predictive collision detection
Opening the old man's hut door
Approach 1 – collision detection
Creating new assets
Character collision detection
Working with OnCollisionEnter
Writing the OpenDoor() method
Declaring the function
Checking the door status
Playing an audio event
Testing the script
Extending colliders
Playing door animations through Animator
Reversing the procedure
Code maintainability
Drawbacks of collision detection
Approach 2 – ray casting
Disabling collision detection with comments
Refactoring the code – writing a Door Manager class
Tidying PlayerCollisions
Casting the ray
Resetting the collider
Approach 3 – trigger collision detection
Creating and scaling the trigger zone
Scripting for trigger collisions
Removing the PlayerCollisions component
Placing additional models
Unity Navigation System
The Bake tab
The Agents tab
The Object tab
The Areas tab
Area Types and Navigation cost
Area mask
Summary
AI, NPC, and Further Scripting
Creating an NPC
Initial code and Animator Controller
Animator transitions
Navigation setup
Baking the NavMesh
Adding the rock stone and NPCsitSpot and NPCStartSpot points
Writing the Simple AI class
NPC interaction
Triggering the dialogue
Writing the DialogueManager class
Tying up the logic and UI events
Driving Animator Blend Tree with scripting
Creating a basic UI for displaying the dialogue
Creating the Canvas
Creating the start dialogue prompt
Creating the dialogue window
Creating the answer buttons
Making enemy AI
Using Unity Standard Assets in our favor
Making the AI smarter
Duplicate ThirdPersonCharacter class
Creating the Advanced AI Controller class
Custom AI state machine
Waypoints roaming
Chasing the target
Back to waypoints roaming
Enemy's Field Of View (or line of sight)
Player presence awareness
Fighting the player
Modifying the chase method
Debugging the Nav Mesh Agent
A better look for our custom components with PropertyDrawers
Further lectures and ideas
Tips for enhancing the AI
Summary
Item Collection, Player Inventory, and HUD
Creating the ancient artifact piece prefabs
Downloading, importing, and placing
Tagging the artifact piece
Collider scaling and rotation
Enlarging the artifact piece
Adding a trigger collider
Collider scale and custom point light
Creating the artifact piece collection script
Making it spin
Adding trigger collision detection
Saving as a prefab
Placing the artifact pieces
Player inventory
Saving the artifact collected piece count value
Setting the variable start value
Audio feedback
Adding the PiecePickup() method
Adding the inventory to the player
Restricting hidden piece spot access
Restricting dialog access with a piece counter
Displaying the game progression status HUD
Import settings for UI images
Creating the HUD panel and background UI image
Scripting for UI image activation
Understanding arrays
Adding QuestIndicator images
Draw order of elements
Disabling the HUD for game start
Enabling the HUD
Hints for the player
Writing on screen with UI Text
Scripting for UI Text control
Adjusting hints to show progress
Summary
Instantiation and Rigidbodies
Implementing instantiation
Physics
Forces
The Rigidbody component
Designing the gameplay
Creating the heavy stone prefab
Adding physics to the stone prefab
Saving as a prefab
Throwing stones at guards
The StoneLauncher component
Checking for player input
Writing the Fight method
Instantiating the heavy stone
Naming instances
Assigning velocity
Adding development safeguards
Checking component presence
Safeguarding collisions
Using the IgnoreCollision() method
Ignoring collisions with layers
Final tweaks
Instantiation restriction and object tidying
Implementing stone throw animation
Activating the stone launch at the right frame
Removing stones in a smart way
Finishing touches
Ragdoll physics simulation
Scripting the ragdoll simulation
Reviving the enemy
Using coroutines to time game elements
Collision detection
Punching the guards
Playing stones collisions feedback sounds
Adding force impulse to stones impacts
Summary
Unity Particle System
What is a Particle System?
Creating the fireplace
Creating wall torches
Modifying the Fire Light component
Enhancing environment ambience
Making the village ground dusty
Creating a sea breeze particle system
The Gradient Editor
Creating a waterfall
Summary
Designing Menus with Unity UI
Unity UI
Canvas render modes
Screen space – overlay
Screen space – camera
World space
Preparing textures for UI usage
Creating the main menu scene
Adding the game title
Manually anchoring the title to the Canvas
Creating the main menu panel
Adding buttons
Clone the MainMenu to obtain the Options menu
Configuring UI buttons to show/hide menus with the OnClick() event method
Creating an audio options menu
Adding music volume control
Adding general volume control
Writing a listener script for UI slider elements
User interaction
Creating a video options menu
The power of UI dynamic variables and UI events
Creating a drop-down menu
Yet another slider controller
Loading the game
Final touches
Lights and shadows
Adding a Rim light
Real-time shadows
Post-processing image effects
FSAA (Full Screen Anti-Aliasing)
Bloom and HDR
Screen overlay
Vignette and chromatic aberration
Splitting the render on two different cameras
Adding jail bars to the scene
Conclusion
Testing screen sizes
Further looks
Summary
Optimization and Final Touches
Tweaking the terrain
Using SpeedTree
Hills, troughs, rocks, and texture blending
Smoothing and painting
Keep on the right path by drawing path details with splat maps
Some level design: placing the guards
Unity lighting
Scene setup
The Enviroment settings
Realtime lighting and Mixed Lighting
Realtime only versus Baked only versus Mixed lighting
Lightmaps and baked Global Illumination
Baking the scene
Preparing for lighting
Including or excluding lights from the baking
Excluding GameObjects from the bake
Baking the scene
Lightmapping Settings
Global maps
Object maps
Other settings
Optimizing performance
Camera clip planes (frustum culling)
Standard fog versus Global Fog post effect
Occlusion culling
The Object tab
The Bake tab
The Visualization tab
Wrapping it all up
Rendering paths
Graphics pipelines
Forward Rendering
Deferred Rendering
Lighting performance
Should I use Deferred?
Physical-Based Rendering: Unity Standard Shader
Image effects
Hardware-based anti-aliasing (MSAA) versus shader-based anti-aliasing(FSAA)
Depth of field
Debugging depth of field
Crepuscular sun rays through Sun Shafts effect
The Post Processing Stack
Post Processing Stack V2 and Utilities
Focus puller
Advanced rendering features
Level of Detail (LOD)
High Dynamic Range
Asynchronous Texture Upload
Graphic Command buffers
Unity Engine automated optimizations
Static and dynamic batching
Static batching
Dynamic batching
GPU instancing
Cull and cull more!
Camera culling distance
Modifying the FireLight class
Further optimizations
Physics optimizations
Writing the DeactivateRagdollTimer class
Changing the HeavyStone class
Exercise proposal: a rough save game-status feature
Optimizing AI impact on the CPU
Setting up AI Trigger areas
Other ideas
Summary
Building and Sharing
Supported platforms
PC (Windows), Linux, or Mac standalone
Android platform
iOS
WebGL
Virtual, augmented, and mixed reality
Player settings
Cross-platform general settings
Per-platform player settings
Mac - PC - Linux - standalone build
Resolution and Presentation
User input bindings
Icon
Splash image
Splash screen
Logos
Background
Other settings
Rendering
Configuration and optimization
Logging
XR settings
Android
iOS
WebGL
Player input settings
Graphics settings
Tier settings
Quality settings
Quality settings - Rendering
Quality settings - Shadows
Quality settings – Other
Building the game
Build settings
Quit button with platform automation
Our first build
Building the standalone for PC/Mac/Linux
Adapting for the web
Building for the web
Adapting and building for the mobile platform
Adapting for Android
Texture Compression formats
Building for Android
Choosing the preferred build system
Publishing settings
Building for iOS
Testing and debugging
Debugging with Visual Studio 2017
Testing and profiling with Unity Editor
Unity Profiler
The Physics Debug window
The Frame Debug window
Sharing your work
Sharing WebGL builds
Publishing on mobile stores
Publishing for the desktop
Digital Content Creation tools
Future of Unity and MonoBehaviour
Testing and further study
Learn by doing
Testing and finalizing
Public alpha testing and open beta
Frame rate feedback
Testing different video resolutions
Optimizing more
Approaches to learning
Don't reinvent the wheel
Editor extensions
Complete projects
If you don't know how to do it, just ask!
Summary
Other Books You May Enjoy
Leave a review - let other readers know what you think
← Prev
Back
Next →
← Prev
Back
Next →