O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

C# Game Programming Cookbook for Unity 3D

Book Description

An Accessible, Modular Style of Game Building-Easily Start Making Games with Unity 3DC# Game Programming Cookbook for Unity 3D presents a highly flexible core framework to create just about any type of game by plugging in different script components. Most scripts function within the game framework or in your own structures. The techniques and conce

Table of Contents

  1. Acknowledgments
  2. Introduction
    1. Prerequisites
    2. What This Book Doesn’t Cover
  3. Chapter 1 - Making Games the Modular Way
    1. 1.1 Important Programming Concepts
      1. 1.1.1 Manager and Controller Scripts
      2. 1.1.2 Script Communication
      3. 1.1.3 Using the Singleton Pattern in Unity
      4. 1.1.4 Inheritance
      5. 1.1.5 Where to Now?
  4. Chapter 2 - Building the Core Game Framework
    1. 2.1 Controllers and Managers
      1. 2.1.1 Controllers
      2. 2.1.2 Managers
    2. 2.2 Building the Core Framework Scripts
      1. 2.2.1 BaseGameController.cs
        1. 2.2.1.1 Script Breakdown
      2. 2.2.2 Scene Manager
        1. 2.2.2.1 Script Breakdown
      3. 2.2.3 ExtendedCustomMonoBehavior.cs
      4. 2.2.4 BaseUserManager.cs
        1. 2.2.4.1 Script Breakdown
      5. 2.2.5 BasePlayerManager.cs
        1. 2.2.5.1 Script Breakdown
      6. 2.2.6 BaseInputController.cs
        1. 2.2.6.1 Script Breakdown
  5. Chapter 3 - Player Structure
    1. 3.1 Game-Specific Player Controller
    2. 3.2 Dealing with Input
    3. 3.3 Player Manager
      1. 3.3.1 Script Breakdown
    4. 3.4 User Data Manager (Dealing with Player Stats Such as Health, Lives, etc.)
      1. 3.4.1 Script Breakdown
  6. Chapter 4 - Recipes: Common Components
    1. 4.1 Introduction
    2. 4.2 The Timer Class
      1. 4.2.1 Script Breakdown
    3. 4.3 Spawn Scripts
      1. 4.3.1 A Simple Spawn Controller
        1. 4.3.1.1 Script Breakdown
      2. 4.3.2 Trigger Spawner
      3. 4.3.3 Path Spawner
        1. 4.3.3.1 Script Breakdown
    4. 4.4 Set Gravity
    5. 4.5 Pretend Friction—Friction Simulation to Prevent Slipping Around
      1. 4.5.1 Script Breakdown
    6. 4.6 Cameras
      1. 4.6.1 Third-Person Camera
        1. 4.6.1.1 Script Breakdown
      2. 4.6.2 Top-Down Camera
        1. 4.6.2.1 Script Breakdown
    7. 4.7 Input Scripts
      1. 4.7.1 Mouse Input
        1. 4.7.1.1 Script Breakdown
      2. 4.7.2 Single Axis Keyboard Input
    8. 4.8 Automatic Self-Destruction Script
      1. 4.8.1 Script Breakdown
    9. 4.9 Automatic Object Spinner
      1. 4.9.1 Script Breakdown
    10. 4.10 Scene Manager
      1. 4.10.1 Script Breakdown
  7. Chapter 5 - Building Player Movement Controllers
    1. 5.1 Shoot ’Em Up Spaceship
    2. 5.2 Humanoid Character
      1. 5.2.1 Script Breakdown
    3. 5.3 Wheeled Vehicle
      1. 5.3.1 Script Breakdown
      2. 5.3.2 Wheel Alignment
      3. 5.3.3 Script Breakdown
  8. Chapter 6 - Weapon Systems
    1. 6.1 Building the Scripts
      1. 6.1.1 BaseWeaponController.cs
        1. 6.1.1.1 Script Breakdown
      2. 6.1.2 BaseWeaponScript.cs
        1. 6.1.2.1 Script Breakdown
  9. Chapter 7 - Recipe: Waypoints Manager
    1. 7.1 Waypoint System
  10. Chapter 8 - Recipe: Sound Manager
    1. 8.1 The Sound Controller
      1. 8.1.1 Script Breakdown
    2. 8.2 The Music Player
      1. 8.2.1 Script Breakdown
    3. 8.3 Adding Sound to the Weapons
  11. Chapter 9 - AI Manager
    1. 9.1 The AI State Control Script
    2. 9.2 The Base AI Control Script
      1. 9.2.1 Script Breakdown
    3. 9.3 Adding Weapon Control to the AI Controller
      1. 9.3.1 Script Breakdown
  12. Chapter 10 - Menus and User Interface
    1. 10.1 The Main Menu
      1. 10.1.1 Script Breakdown
    2. 10.2 In-Game User Interface
  13. Chapter 11 - Dish: Lazer Blast Survival
    1. 11.1 Main Menu Scene
    2. 11.2 Main Game Scene
    3. 11.3 Prefabs
    4. 11.4 Ingredients
    5. 11.5 Game Controller
      1. 11.5.1 Script Breakdown
    6. 11.6 Player Controller
      1. 11.6.1 Script Breakdown
    7. 11.7 Enemies
      1. 11.7.1 Script Breakdown
    8. 11.8 Wave Spawning and Control
      1. 11.8.1 Script Breakdown
    9. 11.9 Wave Properties
    10. 11.10 Weapons and Projectiles
    11. 11.11 User Interface
      1. 11.11.1 Script Breakdown
  14. Chapter 12 - Dish: Metal Vehicle Doom
    1. 12.1 Main Menu Scene
    2. 12.2 Main Game Scene
      1. 12.2.1 Prefabs
    3. 12.3 Ingredients
      1. 12.3.1 Game Controller
        1. 12.3.1.1 Script Breakdown
      2. 12.3.2 Race Controller
        1. 12.3.2.1 Script Breakdown
      3. 12.3.3 Global Race Manager
        1. 12.3.3.1 Script Breakdown
      4. 12.3.4 Vehicle/Custom Player Control
        1. 12.3.4.1 Script Breakdown
      5. 12.3.5 User Interface
  15. Chapter 13 - Dish: Making the Game Tank Battle
    1. 13.1 Main Game Scene
    2. 13.2 Prefabs
    3. 13.3 Ingredients
    4. 13.4 Game Controller
      1. 13.4.1 Script Breakdown
    5. 13.5 Battle Controller
      1. 13.5.1 Script Breakdown
    6. 13.6 Global Battle Manager
      1. 13.6.1 Script Breakdown
    7. 13.7 Players
      1. 13.7.1 Script Breakdown
    8. 13.8 AI Chasing with SetAIChaseTargetBasedOnTag.cs
      1. 13.8.1 Script Breakdown
  16. Chapter 14 - Dish: Making the Game Interstellar Paranoids
    1. 14.1 Main Menu
    2. 14.2 Game Scenes
    3. 14.3 Prefabs
      1. 14.3.1 Ingredients
      2. 14.3.2 Game Controller
        1. 14.3.2.1 Script Breakdown
      3. 14.3.3 Player Spaceship
        1. 14.3.3.1 Script Breakdown
      4. 14.3.4 Enemies
        1. 14.3.4.1 Script Breakdown
      5. 14.3.5 Waypoint Follower
        1. 14.3.5.1 Script Breakdown
  17. Final Note