Book Image

Unity Game Development Scripting

By : D'Aoust
Book Image

Unity Game Development Scripting

By: D'Aoust

Overview of this book

The intuitive and powerful Unity game engine is one of the most widely used and best loved packages for game development. Unity scripting is an essential but challenging skill to master in order to create custom game elements. Learning modular scripting allows you to rewrite as little code as possible as you deploy your scripts to multiple projects and work easier, quicker, and more efficiently than before. In each chapter of this book, you'll learn how to script new game elements. Beginning with making custom controls for the keyboard and mouse, as well as the Xbox 360 Controller, you'll then get to grips with more complex systems such as inventory, data saving, and artificial intelligence. As you create these elements, you'll also learn how to make your scripts simpler and easy to use. This will allow drag-and-drop deployment, which is to be used by designers and nonprogrammers. Finally, you'll combine all of your newfound skills to create your own complete game project.
Table of Contents (12 chapters)
11
Index

Chapter 1. Interactive Input

Before we start creating our game, it is a good idea to figure out our controls. We'll create a script that will hold our inputs, and create control profiles for both the keyboard/mouse as well as the Xbox 360 Controller. Then, we'll add functionalities to be able to switch between the profiles and customize them as well. Control configurations like these are a key element to games, especially PC games.

In this chapter, we will cover the following topics:

  • Creating controls for the Xbox 360 Controller
  • Creating controls for a keyboard
  • Writing a function to detect whether our controller device is plugged in
  • Customizing our controls
  • Letting players switch controls
  • Switching controls with Graphical User Interface (GUI) buttons
  • Resetting controls back to factory settings