Unity 3.x. Game Development Essentials. Game development with C# and Javascript PUBLISHING

Similar documents
Unity Game Development Essentials

Beginning 3D Game Development with Unity:

Experiment 02 Interaction Objects

The purpose of this document is to outline the structure and tools that come with FPS Control.

Space Invadersesque 2D shooter

COMPASS NAVIGATOR PRO QUICK START GUIDE

Instructions for using Object Collection and Trigger mechanics in Unity

Learn Unity by Creating a 3D Multi-Level Platformer Game

TATAKAI TACTICAL BATTLE FX FOR UNITY & UNITY PRO OFFICIAL DOCUMENTATION. latest update: 4/12/2013

3D Top Down Shooter By Jonay Rosales González AKA Don Barks Gheist

Chapter 1:Object Interaction with Blueprints. Creating a project and the first level

Creating Bullets in Unity3D (vers. 4.2)

Beginning ios 3D Unreal

By Chris Burton. User Manual v1.60.5

CMSC 425: Lecture 3 Introduction to Unity

VR Easy Getting Started V1.3

INTRODUCTION TO GAME AI

First Steps in Unity3D

True bullet 1.03 manual

Unity Certified Programmer

Adding in 3D Models and Animations

A VIRTUAL TOUR OF THE MEDIANA ARCHEOLOGICAL PARK USING UNITY 3D ENGINE

Crowd-steering behaviors Using the Fame Crowd Simulation API to manage crowds Exploring ANT-Op to create more goal-directed crowds

The 8 th International Scientific Conference elearning and software for Education Bucharest, April 26-27, / X

Save System for Realistic FPS Prefab. Copyright Pixel Crushers. All rights reserved. Realistic FPS Prefab Azuline Studios.

PoolKit - For Unity.

Ball Color Switch. Game document and tutorial

Foreword Thank you for purchasing the Motion Controller!

Introduction. Modding Kit Feature List

Macquarie University Introductory Unity3D Workshop

Shoot It Game Template - 1. Tornado Bandits Studio Shoot It Game Template - Documentation.

..... l ss t h t an an $100,000 of 000 of ann an u n al u al gross r evenu n e

Appendix A ACE exam objectives map

Workshop 4: Digital Media By Daniel Crippa

EVAC-CITY. Index. A starters guide to making a game like EVAC-CITY

Heavy Station Kit base 2

Installation Instructions

Spell Casting Motion Pack 8/23/2017

Kings! Card Swiping Decision Game Asset

Game Design Document (GDD)

Module 4 Build a Game

Procedural Level Generation for a 2D Platformer

Catch The Kites A Lightweight Android Game

No Evidence. What am I Testing? Expected Outcomes Testing Method Actual Outcome Action Required

Z-Town Design Document

Game Design Document. RELEASE December 18, Austin Krauss

Open World Virtual Reality Role Playing Game

While entry is at the discretion of the centre, it would be beneficial if candidates had the following IT skills:

CS Game Programming, Fall 2014

Mastering Autodesk Navisworks 2013

Warmup Due: Feb. 6, 2018

VACUUM MARAUDERS V1.0

The Archery Motion pack requires the following: Motion Controller v2.23 or higher. Mixamo s free Pro Longbow Pack (using Y Bot)

Annex IV - Stencyl Tutorial

Slime VISIT FOR THE LATEST UPDATES, FORUMS & MORE ASSETS.

3D VR Puzzle for Anatomy Education

12. Creating a Product Mockup in Perspective

LabVIEW 8" Student Edition

Project 1: Game of Bricks

Gaia is a system that enables rapid and precise creation of gorgeous looking Unity terrains. Version March 2016 GAIA. By Procedural Worlds

Control Systems in Unity

Section 39: BobmerMan How-To

Gesture Control FPS Horror/Survivor Game Third Year Project (COMP30040)

Sword & Shield Motion Pack 11/28/2017

6. Graphics MULTIMEDIA & GRAPHICS 10/12/2016 CHAPTER. Graphics covers wide range of pictorial representations. Uses for computer graphics include:

2D Platform. Table of Contents

House Design Tutorial

Sensible Chuckle SuperTuxKart Concrete Architecture Report

Creating a First Person Shooter (FPS) Part 2

Unreal Studio Project Template

AngkorVR. Advanced Practical Richard Schönpflug and Philipp Rettig

SteamVR Unity Plugin Quickstart Guide

"!" - Game Modding and Development Kit (A Work Nearly Done) '08-'10. Asset Browser

Attack of Township. Moniruzzaman, Md. Daffodil International University Institutional Repository Daffodil International University

Concrete Architecture of SuperTuxKart

GAME:IT Junior Bouncing Ball

Chapter 7- Lighting & Cameras

UNITY TECHNOLOGY ROADMAP

How to Make Games in MakeCode Arcade Created by Isaac Wellish. Last updated on :10:15 PM UTC

An Approach to Maze Generation AI, and Pathfinding in a Simple Horror Game

Kismet Interface Overview

Tutorial Guide to AutoCAD 2014

This guide will cover the basics of base building, we will be using only the default recipes every character starts out with.

Making Your World with the Aurora Toolset

Tutorial Guide to AutoCAD 2013

DESIGN A SHOOTING STYLE GAME IN FLASH 8

Motion Blur with Mental Ray

Overview. The Game Idea

Game Design Document. Plataforms: Platformer / Puzzle

Tutorial Guide to AutoCAD 2015

Pangolin: A Look at the Conceptual Architecture of SuperTuxKart. Caleb Aikens Russell Dawes Mohammed Gasmallah Leonard Ha Vincent Hung Joseph Landy

An Implementation and Usability Study of a Natural User Interface Virtual Piano

House Design Tutorial

RPG CREATOR QUICKSTART

Easy Input For Gear VR Documentation. Table of Contents

Game Design Comp 150GD. Michael Shah 3/6/15

Evaluating Performance of Point and Shoot in Bow and Arrow Shoot Mobile Game: Touch, Swipe, Rotate, Artificial Intelligence

Modo VR Technical Preview User Guide

Fundamental Game Systems Implemented in Unreal Engine 4 For Use With or Without Oculus Rift

Transcription:

Unity 3.x Game Development Essentials Game development with C# and Javascript Build fully functional, professional 3D games with realistic environments, sound, dynamic effects, and more! Will Goldstone PUBLISHING BIRMINGHAM - MUMBAI

Preface 1 Chapter 1: Enter the Third Dimension 7 Getting to grips with 3D 7 Coordinates 8 Local space versus world space 9 Vectors 11 Cameras 11 Projection mode 3D versus 2D 11 Polygons, edges, vertices, and meshes 12 Materials, textures, and shaders 14 Rigidbody physics 15 Collision detection 16 Essential Unity concepts 17 The Unity way an example 18 Assets 19 Scenes 19 GameObjects 19 Components 20 Scripts 20 Prefabs 21 The interface 22 The Scene view and Hierarchy 23 Control tools 23 Flythrough Scene navigation 24 Control bar 24 Search box 25 Create button 25 The Inspector 25 The Project window 26

The Game view 27 Summary 28 Chapter 2: Prototyping and Scripting Basics 29 Your first Unity project 29 A basic prototyping environment 31 Setting the scene 32 Adding simple lighting 33 Another brick in the wall 34 Building the master brick 34 And snap! It's a row 36 Grouping and duplicating with empty objects 38 Build it up, knock it down! 39 Setting the viewpoint 39 Introducing scripting 39 A new behaviour script or 'class' 40 What's inside a new C# behaviour 41 Basic functions 42 Variables in C# 42 What's inside a new Javascript behaviour 43 Variables in Javascript 43 Comments 44 Wall attack 44 Declaring public variables 45 Assigning scripts to objects 46 Moving the camera 47 Local, private, and public variables 49 Understanding Translate 50 Implementing Translate 51 Testing the game so far 52 Making a projectile 53 Creating the projectile prefab 53 Creating and applying a material 54 Adding physics with a Rigidbody 55 Storing with prefabs 55 Firing the projectile 56 Using Instantiate!) to spawn objects 56 Adding a force to the Rigidbody 57 Summary 59 Chapter 3: Creating the Environment 61 Designing the game 61 Using the terrain editor 63 Terrain menu features 64 Importing and exporting heightmaps 64

Setting the resolution 64 Mass place trees 66 Flatten Heightmap 66 Refresh tree and detail prototypes 66 The terrain toolset 66 Terrain Script 66 Raise height 67 Paint height 68 Smooth Height 69 Paint Texture 70 Place Trees 70 Paint Details 71 Terrain Settings 71 Creating the island sun, sea, and sand 72 Step 1 Setting up the terrain 72 Step 2 Creating the Island outline 73 Step 3 Volcano! 74 Step 4 Adding textures 76 Step 5 Tree time 80 Step 6 The grass is always greener 81 Step 7 Let there be lights! 83 Step 8 What's that sound? 84 Step 9 Look, there! Up in the skybox! 87 Step 10 Open water 88 Step 11 Going walkabout 88 Step 12 Final tweaks 90 Summary 91 Chapter 4: Player Characters and Further Scripting 93 Working with the Inspector 94 Tags 95 Layers 96 Prefabs and the Inspector 97 Anatomy of a character 97 Deconstructing the First Person Controller object 99 Parent-child issues 99 First Person Controller object 100 Object 1: First Person Controller (parent) 100 Object 2: Graphics (child) 105 Object 3: Main Camera (child) 106 Further scripting 109 Commands 110 Variables 111 Variable data types 111 Using variables 112 Full example 114 Functions 115

UpdateO 115 OnMouseDown() 116 Writing custom functions 116 Return type 116 Arguments 117 Declaring a custom function 118 Calling a custom function 119 If else statements 121 Multiple conditions 123 For loops 124 Inter-script communication and Dot Syntax 125 Accessing other objects 125 Find() and FindWithTagO 126 SendMessage 126 GetComponent 127 Comments 130 Further reading 131 Scripting for character movement 131 Deconstructing the script 131 Full script (Javascript) 131 Variable declaration 132 Storing movement information 133 Moving the character 135 Checking grounded 136 @Script commands 137 Summary 137 Chapter 5: Interactions 139 External modeling applications 139 Common settings for models 140 Meshes 140 Normals and Tangents 141 Materials 142 Animations 142 Animation Compression 142 Setting up the outpost model 143 Adding the outpost 144 Positioning 144 Rotation 145 Adding colliders 145 Adding the Rigidbody 148 Adding audio 148 Disabling automatic animation 149 [iv]

Collisions and triggers 150 Ray casting 153 The frame miss 153 Predictive collision detection 154 Opening the outpost 156 Approach 1 Collision detection 156 Creating new assets 156 Scripting for character collision detection 157 Approach 2 Ray casting 172 Disabling collision detection with comments 172 Migrating code writing a DoorManager script 173 Tidying PlayerCollisions 175 Casting the ray 176 Resetting the collider 178 Approach 3 Trigger collision detection 179 Creating and scaling the trigger zone 179 Scripting for trigger collisions 182 Summary 184 Chapter 6: Collection, Inventory, and HUD 185 Creating the power cell prefab 187 Downloading, importing, and placing 188 Tagging the power cell 188 Collider scaling and rotation 189 Enlarging the power cell 189 Adding a trigger collider 189 Collider scale 189 Adding the Rigidbody 190 Creating the power cell script 190 Adding rotation 191 Adding Trigger Collision Detection 192 Saving as a prefab 193 Scattering power cells 193 Writing the Player Inventory 195 Saving the charge value 195 Setting the variable start value 196 Audio feedback 196 Adding the CellPickup() function 196 Adding the Inventory to the player 197 Restricting outpost access 198 Restricting door access with a cell counter 199 Displaying the power cell HUD 200 Import settings for GUI textures 201 Creating the GUITexture object 201 Positioning the PowerGUI texture 202 [v]

203 Scripting for texture swap 203 Understanding arrays 205 Adding the HUD array 206 Assigning textures to the array 207 Disabling the HUD for game start 208 Enabling the HUD during runtime 210 Adding the power generator 214 Signifying door unlock Adding the locked light 214 Switching lights and removing the HUD 2^ 217 Hints for the player Writing on screen with GUIText 217 Scripting for GUIText control 218 Adjusting hints to show progress 221 Using fonts 222 224 Summary Chapter 7: Instantiation and Rigidbodies. Utilizing instantiation 226 Rigidbodies 227 Forces 227 The Rigidbody component 228 Making the mini-game 229 Creating the coconut prefab 230 Creating the textured coconut 230 Adding physics 231 Saving as a prefab 231 Creating the Launcher object 232 Scripting to throw coconuts 234 Checking for player input 236 Playing feedback sound 236 Instantiating the coconut 237 225 Naming instances 238 Assigning velocity 239 Adding development safeguards 240 Final checks 245 Instantiate restriction and object tidying 246 Activating coconut throw 247 Adding the coconut shy shack 250 Import settings 250 Removing coconuts 252 Placement 256 Disabling automatic animation 256 Adding Rigidbodies to moving parts 257 Writing the Coconut collision detection script 257 Assigning the script 264 Creating more targets 265

Winning the game 266 Setting up variables 266 Checking for a win 267 Script assignment 269 Incrementing and decrementing target count 269 Finishing touches 271 Adding the crosshair 271 Informing the player 272 Summary 275 Chapter 8: Particle Systems 277 What is a particle system? 277 Particle Emitter 278 Particle Animator 278 Particle Renderer 279 Creating the task 280 Assets involved 280 Adding the log pile 281 Creating the campfire particle systems 283 Creating fire 283 Blowing smoke! 288 Adding audio to the fire 291 Lighting the fire 293 Adding the matches 293 Creating the matches GUI 296 Collecting the matches 296 Starting the fire 299 Testing and confirming 304 So, what's the problem? 304 Safeguarding with additional conditions 305 Summary 306 Chapter 9: Designing Menus 307 Interfaces and menus 308 Creating the scene 310 Duplicating the island 310 Preparing textures for GUI usage 312 Adding the game title 313 Creating the menu with GUITextures and mouse events 315 Adding the play button 315 GUITexture button script 315 Loading scenes 318 Assigning public variables 319 Testing the button 319 Adding the instructions button 320 [vii]

Adding the quit button 321 Checking scripts with Debug commands 324 Creating the menu with the Unity GUI class and GUI skins 325 Disabling game objects 326 Creating the menu 326 Creating public variables 327 The OnGUI() function 328 Positioning for GUIs 328 Styling GUI buttons with a GUI skin 332 Using textures for GUI button backgrounds 333 Choosing font size for GUI buttons 335 Scripting button actions 340 Adding the Instructions page 344 Summary 350 Chapter 10: Animation Basics 351 Game win sequence 351 Win sequence approach 353 Triggering the win 354 Creating the game win messages 354 Positioning win sequence GUI elements 355 Grouping GUITextures for optimized instantiation 355 Animating with linear interpolation (Lerp) 355 Adjusting animations 358 Storing the win sequence 358 Creating the win object 358 Creating the Fader and using the Animation panel 360 Scaling for various resolutions 361 Starting the Fader from invisibility 362 Animation panel overview 363 Creating an animation clip 364 Creating keyframes 364 Using animation curves 367 Adding animation events 368 Creating and animating the Loading GUI 370 Loading scenes with animation events 372 Storing and instantiating the Loading GUI 373 Loading the win sequence 373 Layering GUITextures 375 Challenge fading in the Island scene 375 Summary 376 Chapter 11: Performance Tweaks and Finishing Touches 377 Terrain tweaks and player position 378 Tweaking the terrain 378 Positioning trees 378

Hills, troughs, and texture blending 379 Life's a beach 380 Keep on the right path 380 Positioning the player 382 Optimizing performance 382 Camera Clip Planes and Fog 383 Lightmapping 384 Lighting and baking the island 384 Preparing for lightmapping 384 Baking the lightmap 389 Restoring dynamic objects 394 Finishing touches 394 Volcano! 394 Positioning the particle system 395 Making the smoke material 397 Particle system settings 397 Adding audio to the volcano 398 Volcano testing 399 Coconut trails 400 Editing the Prefab 400 Trail Renderer component 401 Updating the prefab 402 Summary 404 Chapter 12: Building and Sharing 405 Build options 406 Web Player 407 Web Player Streamed 407 PC or Mac standalone 408 OSX Dashboard Widget 408 Build Settings Player Settings Cross-Platform Settings 410 Per-Platform Settings 411 Quality Settings 415 Player Input settings 418 Building the game 419 Adapting for web build 419 Quit button platform automation 419 Preparing for streaming 421 First Build 427 Building the Standalone 427 Free versus Pro 428 Building for the Web 429 Embedding web player builds in your own site 430 409 410 [ix]

Sharing your work 434 Sharing on Kongregate.com 434 Summary 435 Chapter 13: Testing and Further Study 437 Learn by doing 438 Testing and finalizing 438 Public testing 439 Frame rate feedback 439 Optimizing performance 442 Approaches to learning 443 Cover as many bases as possible 443 Don't reinvent the wheel 444 If you don't know, just ask! 444 Summary 445 Glossary This Glossary is not present in the book but is available as a free download from: http: //www.packtpub. com/sites/default /files/downloads /144.40T Glossary_Final.pdf Index 447