
Unity in Action, Third Edition
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
In Unity in Action, Third Edition, you will learn how to:
Create characters that run, jump, and bump into things
Build 3D first-person shooters and third-person action games
Construct 2D card games and side-scrolling platformers
Script enemies with AI
Improve game graphics by importing models and images
Design an intuitive user interface for your games
Play music and spatially-aware sound effects
Connect your games to the internet for online play
Deploy your games to desktop, mobile, and the web
Thousands of new game developers have chosen Joe Hocking's Unity in Action as their first step toward Unity mastery. Starting with the initial groundwork of a new game development project, you'll quickly start writing custom code instead of clicking together premade scripts. This fully updated third edition comes packed with fully refreshed graphics, Unity's latest features, and coverage of augmented and virtual reality toolkits. You'll master the Unity toolset from the ground up, learning the skills to go from application coder to game developer.
Foreword by Jesse Schell.
About the technology
Writing games is rewarding and fun-and with Unity, it's easy to get started! Unity handles the heavy lifting, so you can focus on game play, graphics, and user experience. C# support and a huge ecosystem of prebuilt components help even first-time developers go from the drawing board to the screen fast.
About the book
Unity in Action, Third Edition teaches you to create games with the Unity game platform. It's many 2D, 3D, and AR/VR game examples give you hands-on experience with Unity's workflow tools and state-of-the-art rendering engine. This fully updated third edition presents new coverage of Unity's XR toolkit and shows you how you can start building with virtual and augmented reality.
What's inside
Create characters that run, jump, and bump into things
Script enemies with AI
Play music and spatially-aware sound effects
Deploy your games to desktop, mobile, and the web
About the reader
For programmers who know any object-oriented programming language. Examples are in C#.
About the author
Joe Hocking is a software engineer and Unity expert specializing in interactive media development.
Table of Contents
PART 1 FIRST STEPS
1 Getting to know Unity
2 Building a demo that puts you in 3D space
3 Adding enemies and projectiles to the 3D game
4 Developing graphics for your game
PART 2 GETTING COMFORTABLE
5 Building a Memory game using Unity's 2D functionality
6 Creating a basic 2D platformer
7 Putting a GUI onto a game
8 Creating a third-person 3D game: Player movement and animation
9 Adding interactive devices and items within the game
PART 3 STRONG FINISH
10 Connecting your game to the internet
11 Playing audio: Sound effects and music
12 Putting the parts together into a complete game
13 Deploying your game to players' devices
More details
Other editions
Additional editions

Person
Content
- Intro
- inside front cover
- Praise for earlier editions of Unity in Action
- Unity in Action, Third Edition
- Copyright
- contents
- front matter
- foreword
- preface
- acknowledgments
- about this book
- Who should read this book
- How this book is organized: A roadmap
- About the code
- liveBook discussion forum
- about the author
- about the cover illustration
- Part 1 First steps
- 1 Getting to know Unity
- 1.1 Why is Unity so great?
- 1.1.1 Unity's strengths and advantages
- 1.1.2 Downsides to be aware of
- 1.1.3 Example games built with Unity
- 1.2 How to use Unity
- 1.2.1 Scene view, Game view, and the Toolbar
- 1.2.2 The mouse and keyboard
- 1.2.3 The Hierarchy view and the Inspector panel
- 1.2.4 The Project and Console tabs
- 1.3 Getting up and running with Unity programming
- 1.3.1 Running code in Unity: Script components
- 1.3.2 Using Visual Studio, the included IDE
- 1.3.3 Printing to the console: Hello World!
- Summary
- 2 Building a demo that puts you in 3D space
- 2.1 Before you start . . .
- 2.1.1 Planning the project
- 2.1.2 Understanding 3D coordinate space
- 2.2 Begin the project: Place objects in the scene
- 2.2.1 The scenery: Floor, outer walls, and inner walls
- 2.2.2 Lights and cameras
- 2.2.3 The player's collider and viewpoint
- 2.3 Make things move: A script that applies transforms
- 2.3.1 Visualizing how movement is programmed
- 2.3.2 Writing code to implement the diagram
- 2.3.3 Understanding local vs. global coordinate space
- 2.4 Script component for looking around: MouseLook
- 2.4.1 Horizontal rotation that tracks mouse movement
- 2.4.2 Vertical rotation with limits
- 2.4.3 Horizontal and vertical rotation at the same time
- 2.5 Keyboard input component: First-person controls
- 2.5.1 Responding to keypresses
- 2.5.2 Setting a rate of movement independent of the computer's speed
- 2.5.3 Moving the CharacterController for collision detection
- 2.5.4 Adjusting components for walking instead of flying
- Summary
- 3 Adding enemies and projectiles to the 3D game
- 3.1 Shooting via raycasts
- 3.1.1 What is raycasting?
- 3.1.2 Using the ScreenPointToRay command for shooting
- 3.1.3 Adding visual indicators for aiming and hits
- 3.2 Scripting reactive targets
- 3.2.1 Determining what was hit
- 3.2.2 Alerting the target that it was hit
- 3.3 Basic wandering AI
- 3.3.1 Diagramming how basic AI works
- 3.3.2 "Seeing" obstacles with a raycast
- 3.3.3 Tracking the character's state
- 3.4 Spawning enemy prefabs
- 3.4.1 What is a prefab?
- 3.4.2 Creating the enemy prefab
- 3.4.3 Instantiating from an invisible SceneController
- 3.5 Shooting by instantiating objects
- 3.5.1 Creating the projectile prefab
- 3.5.2 Shooting the projectile and colliding with a target
- 3.5.3 Damaging the player
- Summary
- 4 Developing graphics for your game
- 4.1 Understanding art assets
- 4.2 Building basic 3D scenery: Whiteboxing
- 4.2.1 Whiteboxing explained
- 4.2.2 Drawing a floor plan for the level
- 4.2.3 Laying out primitives according to the plan
- 4.3 Texturing the scene with 2D images
- 4.3.1 Choosing a file format
- 4.3.2 Importing an image file
- 4.3.3 Applying the image
- 4.4 Generating sky visuals by using texture images
- 4.4.1 What is a skybox?
- 4.4.2 Creating a new skybox material
- 4.5 Working with custom 3D models
- 4.5.1 Which file format to choose?
- 4.5.2 Exporting and importing the model
- 4.6 Creating effects by using particle systems
- 4.6.1 Adjusting parameters on the default effect
- 4.6.2 Applying a new texture for fire
- 4.6.3 Attaching particle effects to 3D objects
- Summary
- Part 2 Getting comfortable
- 5 Building a Memory game using Unity's 2D functionality
- 5.1 Setting up everything for 2D graphics
- 5.1.1 Preparing the project
- 5.1.2 Displaying 2D images (aka sprites)
- 5.1.3 Switching the camera to 2D mode
- 5.2 Building a card object and making it react to clicks
- 5.2.1 Building the object out of sprites
- 5.2.2 Mouse input code
- 5.2.3 Revealing the card on a click
- 5.3 Displaying the various card images
- 5.3.1 Loading images programmatically
- 5.3.2 Setting the image from an invisible SceneController
- 5.3.3 Instantiating a grid of cards
- 5.3.4 Shuffling the cards
- 5.4 Making and scoring matches
- 5.4.1 Storing and comparing revealed cards
- 5.4.2 Hiding mismatched cards
- 5.4.3 Text display for the score
- 5.5 Restart button
- 5.5.1 Programming a UIButton component by using SendMessage
- 5.5.2 Calling LoadScene from SceneController
- Summary
- 6 Creating a basic 2D platformer
- 6.1 Setting up the graphics
- 6.1.1 Placing the scenery
- 6.1.2 Importing sprite sheets
- 6.2 Moving the player left and right
- 6.2.1 Writing keyboard controls
- 6.2.2 Colliding with the block
- 6.3 Playing the sprite's animation
- 6.3.1 Explaining the Mecanim animation system
- 6.3.2 Triggering animations from code
- 6.4 Adding the ability to jump
- 6.4.1 Falling from gravity
- 6.4.2 Applying an upward impulse
- 6.4.3 Detecting the ground
- 6.5 Additional features for a platform game
- 6.5.1 Unusual floors: Slopes and one-way platforms
- 6.5.2 Implementing moving platforms
- 6.5.3 Camera control
- Summary
- 7 Putting a GUI onto a game
- 7.1 Before you start writing code . . .
- 7.1.1 Immediate mode GUI or advanced 2D interface?
- 7.1.2 Planning the layout
- 7.1.3 Importing UI images
- 7.2 Setting up the GUI display
- 7.2.1 Creating a canvas for the interface
- 7.2.2 Buttons, images, and text labels
- 7.2.3 Controlling the position of UI elements
- 7.3 Programming interactivity in the UI
- 7.3.1 Programming an invisible UIController
- 7.3.2 Creating a pop-up window
- 7.3.3 Setting values using sliders and input fields
- 7.4 Updating the game by responding to events
- 7.4.1 Integrating an event system
- 7.4.2 Broadcasting and listening for events from the scene
- 7.4.3 Broadcasting and listening for events from the HUD
- Summary
- 8 Creating a third-person 3D game: Player movement and animation
- 8.1 Adjusting the camera view for third-person
- 8.1.1 Importing a character to look at
- 8.1.2 Adding shadows to the scene
- 8.1.3 Orbiting the camera around the player character
- 8.2 Programming camera-relative movement controls
- 8.2.1 Rotating the character to face movement direction
- 8.2.2 Moving forward in that direction
- 8.3 Implementing the jump action
- 8.3.1 Applying vertical speed and acceleration
- 8.3.2 Modifying the ground detection to handle edges and slopes
- 8.4 Setting up animations on the player character
- 8.4.1 Defining animation clips in the imported model
- 8.4.2 Creating the animator controller for these animations
- 8.4.3 Writing code that operates the animator
- Summary
- 9 Adding interactive devices and items within the game
- 9.1 Creating doors and other devices
- 9.1.1 Doors that open and close on a keypress
- 9.1.2 Checking distance and facing before opening the door
- 9.1.3 Operating a color-changing monitor
- 9.2 Interacting with objects by bumping into them
- 9.2.1 Colliding with physics-enabled obstacles
- 9.2.2 Operating the door with a trigger object
- 9.2.3 Collecting items scattered around the level
- 9.3 Managing inventory data and game state
- 9.3.1 Setting up player and inventory managers
- 9.3.2 Programming the game managers
- 9.3.3 Storing inventory in a collection object: List vs. Dictionary
- 9.4 Inventory UI for using and equipping items
- 9.4.1 Displaying inventory items in the UI
- 9.4.2 Equipping a key to use on locked doors
- 9.4.3 Restoring the player's health by consuming health packs
- Summary
- Part 3 Strong finish
- 10 Connecting your game to the internet
- 10.1 Creating an outdoor scene
- 10.1.1 Generating sky visuals by using a skybox
- 10.1.2 Setting up an atmosphere that's controlled by code
- 10.2 Downloading weather data from an internet service
- 10.2.1 Requesting HTTP data using coroutines
- 10.2.2 Parsing XML
- 10.2.3 Parsing JSON
- 10.2.4 Affecting the scene based on weather data
- 10.3 Adding a networked billboard
- 10.3.1 Loading images from the internet
- 10.3.2 Displaying images on the billboard
- 10.3.3 Caching the downloaded image for reuse
- 10.4 Posting data to a web server
- 10.4.1 Tracking current weather: Sending post requests
- 10.4.2 Server-side code in PHP
- Summary
- 11 Playing audio: Sound effects and music
- 11.1 Importing sound effects
- 11.1.1 Supported file formats
- 11.1.2 Importing audio files
- 11.2 Playing sound effects
- 11.2.1 Explaining what's involved: Audio clip vs. source vs. listener
- 11.2.2 Assigning a looping sound
- 11.2.3 Triggering sound effects from code
- 11.3 Using the audio control interface
- 11.3.1 Setting up the central AudioManager
- 11.3.2 Volume control UI
- 11.3.3 Playing UI sounds
- 11.4 Adding background music
- 11.4.1 Playing music loops
- 11.4.2 Controlling music volume separately
- 11.4.3 Fading between songs
- Summary
- 12 Putting the parts together into a complete game
- 12.1 Building an action RPG by repurposing projects
- 12.1.1 Assembling assets and code from multiple projects
- 12.1.2 Programming point-and-click controls: Movement and devices
- 12.1.3 Replacing the old GUI with a new interface
- 12.2 Developing the overarching game structure
- 12.2.1 Controlling mission flow and multiple levels
- 12.2.2 Completing a level by reaching the exit
- 12.2.3 Losing the level when caught by enemies
- 12.3 Handling the player's progression through the game
- 12.3.1 Saving and loading the player's progress
- 12.3.2 Beating the game by completing three levels
- Summary
- 13 Deploying your game to players' devices
- 13.1 Start by building for the desktop: Windows, Mac, and Linux
- 13.1.1 Building the application
- 13.1.2 Adjusting player settings: Setting the game's name and icon
- 13.1.3 Platform-dependent compilation
- 13.2 Building for the web
- 13.2.1 Building the game embedded in a web page
- 13.2.2 Communicating with JavaScript in the browser
- 13.3 Building for mobile: iOS and Android
- 13.3.1 Setting up the build tools
- 13.3.2 Texture compression
- 13.3.3 Developing plugins
- 13.4 Developing XR (both VR and AR)
- 13.4.1 Supporting virtual reality headsets
- 13.4.2 AR Foundation for mobile Augmented Reality
- Summary
- afterword
- Game design
- Marketing your game
- Appendix A. Scene navigation and keyboard shortcuts
- A.1 Scene navigation using the mouse
- A.2 Commonly used keyboard shortcuts
- Appendix B. External tools used alongside Unity
- B.1 Programming tools
- B.1.1 Rider
- B.1.2 Xcode
- B.1.3 Android SDK
- B.1.4 Version control (Git, SVN)
- B.2 3D art applications
- B.2.1 Maya
- B.2.2 3ds Max
- B.2.3 Blender
- B.2.4 SketchUp
- B.3 2D image editors
- B.3.1 Photoshop
- B.3.2 GIMP
- B.3.3 TexturePacker
- B.3.4 Aseprite, Pyxel Edit
- B.4 Audio software
- B.4.1 Pro Tools
- B.4.2 Audacity
- Appendix C. Modeling a bench in Blender
- C.1 Building the mesh geometry
- C.2 Texture-mapping the model
- Appendix D. Online learning resources
- D.1 Additional tutorials
- D.2 Code libraries
- index
- inside back cover
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.