Book Image

Unity 5.x By Example

By : Alan Thorn
Book Image

Unity 5.x By Example

By: Alan Thorn

Overview of this book

Unity is an exciting and popular engine in the game industry. Throughout this book, you’ll learn how to use Unity by making four fun game projects, from shooters and platformers to exploration and adventure games. Unity 5 By Example is an easy-to-follow guide for quickly learning how to use Unity in practical context, step by step, by making real-world game projects. Even if you have no previous experience of Unity, this book will help you understand the toolset in depth. You'll learn how to create a time-critical collection game, a twin-stick space shooter, a platformer, and an action-fest game with intelligent enemies. In clear and accessible prose, this book will present you with step-by-step tutorials for making four interesting games in Unity 5 and explain all the fundamental concepts along the way. Starting from the ground up and moving toward an intermediate level, this book will help you establish a strong foundation in making games with Unity 5.
Table of Contents (15 chapters)
Unity 5.x By Example
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Player input


The Player object is now created in the scene, configured with both Rigidbody and Collider components. However, this object doesn't respond to player controls. In a twin-stick shooter, the player provides input on two axes and can typically shoot a weapon. This often means that keyboard WASD buttons guide player movements up, down, left, and right. In addition, mouse movement controls the direction in which the player is looking and aiming and the left mouse button typically fires a weapon. This is the control scheme required for our game. To implement this, we'll need to create a PlayerController script file. Right-click on the Scripts folder of the Project panel and create a new C# script file named PlayerController.cs. See Figure 3.16:

Figure 3.16: Creating a player controller C# script file

In the PlayerController.cs script file, the following code (as shown in Code Sample 3.1) should be featured. Comments follow this sample:

//------------------------------
using UnityEngine...