Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
About This eBook
Title Page
Copyright Page
Dedication Page
Contents at a Glance
Contents
Preface
Why Write This Book?
Who Is This Book For?
Why Did We Choose to Use Unity?
What Will You Need?
How Much Scripting Is Involved?
How Is the Book Organized?
Conventions Used in This Book
Supplementary Materials
Acknowledgments
About the Authors
Introduction
Introduction to Unity
Downloading and Installing Unity
Project Wizard
Open Project Tab
Create New Project Tab
Packages
Setting Our Project
Project Structure
Folder Organization
File Naming Conventions
1. Setting Up the Unity Development Environment
Welcome Screen
The Unity Interface
Menus
Toolbar
Hierarchy
Inspector
Project Browser
Scene View
Game View
Summary
Exercises
2. Understanding Asset Creation
File Formats
3D Formats
2D Formats
Importing Our Assets
Importing from Inside Unity
Importing Premade Assets from the File Browser
Creating New Assets
Importing Packages
Unity Packages
Custom Packages
GameObjects
Our First GameObject
Creating a GameObject
Components
Creating a Component
Assign a Component
Prefabs
Summary
Exercises
3. Creating 2D Sprites
Working in 2D
2D Behaviors
2D Workspace
Building Our Sprites
Import Settings
Pixels To Units
Sprite Editor
Sprite Packing
Packing Tag
Sprite Packer
Additional Sprite Packing Resources
Summary
Exercises
4. Building the Game World
Level Design 101
Setting the Scene
Creating a Roadmap
Adding Details
Getting around Our Scene
Scene Gizmo
Perspective versus Isometric
Camera Controls
Manipulating Objects in Unity
Transform Tools
Z-Depth
Settings
Our First Level
Positioning GameObjects Manually
Using the Snap Settings to Position GameObjects
Using Grid Snapping to Position GameObjects
Efficient Level Design
Adding Sorting Elements
Continuing On
Summary
Exercises
5. The Basics of Movement and Player Control
Coding in Unity3D
The Three Languages
Choosing the “Right” Language
Making the Player Go
Different Ways of Handling Movement
Creating and Hooking Up Our PlayerController
Setting Up a Basic Follow-Cam
Introducing the Input Manager
Error Handling and Debugging
Handling Exceptions
Try-Catch-Finally—Gracefully Handling Exceptions
Debug.Log() Is Your Friend
Using Breakpoints to Halt Code Execution
Summary
Exercises
6. Adding Animations to Our Scene
Some Rules for Animation
Animation Principles
2D versus 3D Animation
Transform versus Frame Animation
Scripted Animations
Imported Animations
Creating Animations
Animation Component
Animation Clip
Animation Window
Animation Events
Animation States
Animator Controller
Animator Component
Animator Window
Editing the Player Controller
Working with the State Machine
Transitions
Any State
Blend Trees
Summary
Exercises
7. Setting Up Player Physics and Colliders
Understanding Physics
Mass
Gravity
Force
2D versus 3D
6DoF
Z-Depth
Rotations
Physics 2D Settings
General Physics Settings
Layer Collision Matrix
Rigidbodies
Colliders
Circle Collider
Box Collider
Edge Collider
Polygon Collider
Physics Materials
Constraints
Summary
Exercise
8. Creating and Applying Gameplay Systems
Trigger Volumes in Unity
Trigger2D Functions
Adding Trigger Components to GameObjects
Creating Checkpoints
Scripting the Checkpoint Component
Sizing and Placing Our Checkpoint Trigger
Using Checkpoints with Respawn
Preparing the Pit Trigger Volume
Scripting the Pit Trigger Component
Creating Collectibles
Preparing the Floating Coin Prefabs for Collection
Scripting the CoinPickup Component
Preparing the Popped Coin Prefabs for Collection
Preparing the Coin Box Prefabs
Scripting the Coin Box Component
Scripting the CoinSpawner Component
Hooking It All Together
A Touch of Polish
Tracking the Player’s Stats
Summary
Exercises
9. Creating Hazards and Crafting Difficulty
Creating Your First Enemy
Preparing the Slime Enemy GameObject
Inheritance and the EnemyController Component
Scripting the Enemy Slime Component
Adding Walls to the Level
Handling Collision with Other Slimes
Adding Animation to the Slime
Dealing Damage
Scripting Damage into the PlayerStats Component
Creating the Damage Trigger
Passing through the Player’s Space
Adding Damage to the Pits
Adding Temporary Immunity Post-Damage
Visually Representing Immunity, the Classical Way
Handling Player Death
Expanding on Platforming
Preparing the Moving Platform Prefab
Scripting the Flight Points Component
Creating Your Second Enemy
Preparing the Fly Enemy GameObject
Adding Animation to the Fly
Scripting the FlyController Component
Adjusting the FlightPoints Script
Maintaining Your Enemy Arrangements
Preparing the Spawn Trigger
Scripting the Spawn Trigger Component
A Few Words on Challenge
Summary
Exercises
10. Creating the Menus and Interface Elements
UI Design
Diegetic
Non-diegetic
Meta
Spatial
Unity Native GUI
GUI Style
GUI Skin
GUI Controls
Compound Controls
GUI Class
GUI Layouts
GUI Text
GUI Texture
Creating a Splash Screen
Title Screen
Game Over Screen
Game Win Screen
HUD
Creating the Visuals
Creating the Scripts
Summary
Exercise
11. Applying Effects to the GameObjects
Introducing the Shuriken Particle System
Terms to Know
Creating a Particle System
Modules and Properties of a Particle System
Base Particle System Properties
Other Particle System Modules
Particle System Curves
Adding Particle Effects to the Game
Creating a Particle Effect for Coin Boxes
Hooking Up the Coin Box Particle Effect
Creating a Particle Effect for Damage
Calling the Damage Particle System from Code
Having a Little Particle Fun
Unity’s Audio System
The Audio Source Component
The Audio Listener Component
The Audio Reverb Zone Component
Adding Sound to the Player
Adding Footsteps to the Walk Cycle
Adding Sound to the Jump Event
Adding Sound to the Damage Event
Adding Sound to the Collectible System
Applying Sound to the Coin Box
Applying Sound to Coin Collection
Applying Some Extra Polish
Cleaning Up the Camera
Cleaning Up Player Death
Summary
Exercises
12. Organization and Optimization
Organizing Assets
Organizing Our Prefabs
Labels
Hierarchy
Organizing Scripts and Code
Organizing the Script Files
Organizing the Code
Optimizations
Prefabs
Physics
Draw Calls
Triangle Count
Batching
Rendering Statistics Window
Summary
Exercises
13. Bringing It All Together
Tying the Levels Together
Preparing the Victory Trigger Prefab
Creating the Victory Trigger Script
Retrieving the Coin Value
Hooking Up the Intro Screens
Win or Lose: Getting Back into the Action
Recovering from Game Over
Starting Over from a Win
Building and Deploying the Game
Web Player’s Build Settings
PC, Mac, and Linux Standalone Build Settings
Cross-Platform Player Settings
Web Player’s Player Settings
The Right Settings for the Job
Building the Game for the Web Player
Deploying the Game to the Web
Post-Deployment
Moving Forward
Polish Considerations
Monetization
Final Words
14. UGUI
UGUI Components
Creating Our Example Interface
Canvas Component
Rect Transform
UI Rect Tool
Adding the Mask
The Event System and Event Triggers
Summary
Appendix: JavaScript Code Samples
Player Scripts
Collectible Scripts
Enemy Scripts
Game System Scripts
GUI Scripts
Hazard Scripts
System Scripts
Index
Code Snippets
← Prev
Back
Next →
← Prev
Back
Next →