Unity 3.x Game Development Essentials
eBook - ePub

Unity 3.x Game Development Essentials

Game development with C# and Javascript

Will Goldstone

Share book
  1. 488 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Unity 3.x Game Development Essentials

Game development with C# and Javascript

Will Goldstone

Book details
Book preview
Table of contents
Citations

About This Book

In Detail

Game Engines such as Unity are the power-tools behind the games we know and love. Unity is one of the most widely-used and best loved packages for game development and is used by everyone, from hobbyists to large studios, to create games and interactive experiences for the web, desktop, mobile, and console. With Unity's intuitive, easy to learn toolset and this book - it's never been easier to become a game developer.

Taking a practical approach, this book will introduce you to the concepts of developing 3D games, before getting to grips with development in Unity itself - prototyping a simple scenario, and then creating a larger game. From creating 3D worlds to scripting and creating game mechanics you will learn everything you'll need to get started with game development.

This book is designed to cover a set of easy-to-follow examples, which culminate in the production of a First Person 3D game, complete with an interactive island environment. All of the concepts taught in this book are applicable to other types of game, however, by introducing common concepts of game and 3D production, you'll explore Unity to make a character interact with the game world, and build puzzles for the player to solve, in order to complete the game. At the end of the book, you will have a fully working 3D game and all the skills required to extend the game further, giving your end-user, the player, the best experience possible. Soon you will be creating your own 3D games with ease!

Approach

This book follows an informal, demystifying approach to the world of game development with the Unity game engine. With no prior knowledge of game development or 3D required, you will learn from scratch, taking each concept at a time working up to a full 3D mini-game. You'll learn scripting with C# or JavaScript and master the Unity development environment with easy-to-follow stepwise tasks.

Who this book is for

If you're a designer or animator who wishes to take their first steps into game development or prototyping, or if you've simply spent many hours sitting in front of video games, with ideas bubbling away in the back of your mind, Unity and this book should be your starting point. No prior knowledge of game production is required, inviting you to simply bring with you a passion for making great games.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Unity 3.x Game Development Essentials an online PDF/ePUB?
Yes, you can access Unity 3.x Game Development Essentials by Will Goldstone in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming in C#. We have over one million books available in our catalogue for you to explore.

Information

Year
2011
ISBN
9781849691444
Edition
1

Unity 3.xGame Development Essentials

Game development with C# and Javascript


Table of Contents

Unity 3.x Game Development Essentials
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Getting help with the book and updates
Conventions
Reader feedback
Customer support
Downloading the book asset bundle
Downloading the color images of this book
Errata
Piracy
Questions
1. Enter 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
Materials, textures, and shaders
Rigidbody physics
Collision detection
Essential Unity concepts
The Unity way—an example
Assets
Scenes
GameObjects
Components
Scripts
Prefabs
The interface
The Scene view and Hierarchy
Control tools
Flythrough Scene navigation
Control bar
Search box
Create button
The Inspector
The Project window
The Game view
Summary
2. 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
And snap!—It's a row
Grouping and duplicating with empty objects
Build it up, knock it down!
Setting the viewpoint
Introducing scripting
A new behaviour script or 'class'
What's inside a new C# behaviour
Basic functions
Variables in C#
What's inside a new Javascript behaviour
Variables in Javascript
Comments
Wall attack
Declaring public variables
Assigning scripts to objects
Moving the camera
Local, private, and public variables
Local variables and receiving input
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
Storing with prefabs
Firing the projectile
Using Instantiate() to spawn objects
Adding a force to the Rigidbody
Summary
3. Creating the Environment
Designing the game
Using the terrain editor
Terrain menu features
Importing and exporting heightmaps
Setting the resolution
Mass place trees
Flatten Heightmap
Refresh tree and detail prototypes
The terrain toolset
Terrain Script
Raise height
Paint height
Smooth Height
Paint Texture
Place Trees
Paint Details
Terrain Settings
Creating the island—sun, sea, and sand
Step 1—Setting up the terrain
Step 2—Creating the Island outline
Step 3—Volcano!
Step 4—Adding textures
Painting procedure
Sandy areas
Grass & Rock
Volcanoes rock!
Step 5—Tree time
Step 6—The grass is always greener
Step 7—Let there be lights!
Creating sunlight
Step 8—What's that sound?
Sounds—2D versus 3D
Audio file formats
The hills are alive!
Importing the book's asset package
Further audio settings
Step 9—Look, there! Up in the skybox!
Step 10—Open water
Step 11—Going walkabout
Step 12—Final tweaks
Summary
4. Player Characters and Further Scripting
Working with the Inspector
Tags
Layers
Prefabs and the Inspector
Anatomy of a character
Deconstructing the First Person Controller object
Parent-child issues
First Person Controller object
Object 1: First Person Controller (parent)
Transform
Character Controller
Mouse Look (Script)
Character Motor (Script)
FPSInput Controller (Script)
Object 2: Graphics (child)
Mesh filter
Mesh Renderer
Object 3: Main Camera (child)
Camera
GUILayer and Flare Layer
Mouse Look (Script)
Audio listener
Further scripting
Commands
Variables
Variable data types
Using variables
Public versus private variables
Declaring public and private variables
Full example
Functions
Update()
OnMouseDown()
Writing custom functions
Return type
Arguments
Declaring a custom function
Calling a custom function
If else statements
C#:
Multiple conditions
For loops
Inter-script communication and Dot Syntax
Accessing other objects
Find() and FindWithTag()
SendMessage
GetComponent
Programming for Mobile
Dot Syntax
Comments
Further reading
Scripting for character movement
Deconstructing the script
Full script (Javascript)
Variable declaration
Storing movement information
Moving the character
Checking grounded
@Script commands
Summary
5. Interactions
External modeling applications
Common settings for models
Meshes
Normals and Tangents
Materials
Animations
Animation Compression
Setting up the outpost model
Adding the outpost
Positioning
Rotation
Adding colliders
Adding the Rigidbody
Adding audio
Disabling automatic animation
Collisions and triggers
Ray casting
The frame miss
Predictive collision detection
Opening the outpost
Approach 1—Collision detection
Creating new assets
Scripting for character collision detection
Working with OnControllerColliderHit
OpenDoor() custom function
Declaring the function
Checking door status
Playing audio
Testing the script
Extending colliders
Playing animation
Reversing the procedure
Code maintainability
Drawbacks of collision detection
Approach 2—Ray casting
Disabling collision detection with comments
Migrating code—writing a DoorManag...

Table of contents