
- 296 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
C# Game Programming Cookbook for Unity 3D
About this book
This second edition of C# Game Programming Cookbook for Unity 3D expounds upon the first with more details and techniques. With a fresh array of chapters, updated C# code and examples, Jeff W. Murray's book will help the reader understand structured game development in Unity unlike ever before.
New to this edition is a step-by-step tutorial for building a 2D infinite runner game from the framework and scripts included in the book. The book contains a flexible and reusable framework in C# suitable for all game types. From game state handling to audio mixers to asynchronous scene loading, the focus of this book is building a reusable structure to take care of many of the most used systems.
Improve your game's sound in a dedicated audio chapter covering topics such as audio mixers, fading, and audio ducking effects, or dissect a fully featured racing game with car physics, lap counting, artificial intelligence steering behaviors, and game management. Use this book to guide your way through all the required code and framework to build a multi-level arena blaster game.
Features
- Focuses on programming, structure, and an industry-level, C#-based framework
- Extensive breakdowns of all the important classes
- Example projects illustrate and break down common and important Unity C# programming concepts, such as coroutines, singletons, static variables, inheritance, and scriptable objects.
- Three fully playable example games with source code: a 2D infinite runner, an arena blaster, and an isometric racing game
- The script library includes a base Game Manager, timed and proximity spawning, save profile manager, weapons control, artificial intelligence controllers (path following, target chasing and line-of-sight patrolling behaviors), user interface Canvas management and fading, car physics controllers, and more.
Code and screenshots have been updated with the latest versions of Unity. These updates will help illustrate how to create 2D games and 3D games based on the most up-to-date methods and techniques. Experienced C# programmers will discover ways to structure Unity projects for reusability and scalability. The concepts offered within the book are instrumental to mastering C# and Unity.
In his game career spanning more than 20 years, Jeff W. Murray has worked with some of the world's largest brands as a Game Designer, Programmer, and Director. A Unity user for over 14 years, he now works as a consultant and freelancer between developing his own VR games and experiments with Unity.
Frequently asked questions
- Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
- Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Information
1
Making Games in a
Modular Way
1.1Important Programming Concepts
1.1.1 Manager and Controller Scripts
1.1.1.1 Managers
1.1.1.2 Controllers
1.1.1.3 Communication between Classes
- Direct referencing scripts via variables set in the editor by the Inspector window.
- GameObject referencing using SendMessage.
someGameObject.SendMessage(“DoSomething”); - Static variables.
public static GameManager aManager; 1.1.1.4 Public Static
- In our GameManager.cs Game Manager script, we set up a variable, public static typed:
public static gameScore; - In any other script, we can now access this static variable and alter the score as needed:
GameController.gameScore++; 1.1.1.5 Private Static
Private static int uniqueNum; myUniqueNum = uniqueNum; uniqueNum++; 1.1.2 The Singleton
1.1.2.1 Using the Singleton in Unity
public class MyScript : Monobehaviour { private static MySingleton instance; void Awake() { if (instance != null) Destroy(this); instance = this; } } MySingleton.Instance.SomeFunctionInTheSingleton(); 1.1.3 Inheritance
Table of contents
- Cover
- Half Title
- Title Page
- Copyright Page
- Dedication
- Table of Contents
- Acknowledgments
- Introduction
- Prerequisites
- Chapter 1: Making Games in a Modular Way
- Chapter 2: Making a 2D Infinite Runner Game
- Chapter 3: Building the Core Game Framework
- Chapter 4: Player Structure
- Chapter 5: Recipes Common Components
- Chapter 6: Player Movement Controllers
- Chapter 7: Weapon Systems
- Chapter 8: Waypoints Manager
- Chapter 9: Recipe Sound and Audio
- Chapter 10: AI Manager
- Chapter 11: Menus and User Interface
- Chapter 12: Saving and Loading Profiles
- Chapter 13: Loading Level Scenes
- Chapter 14: Racing Game
- Chapter 15: Blaster Game Example
- Index