Book Image

Mastering Unity 5.x

By : Alan Thorn
Book Image

Mastering Unity 5.x

By: Alan Thorn

Overview of this book

Mastering Unity 5.x is for developers wishing to optimize the features of Unity 5.x. With an in-depth focus on a practical project, learn all about Unity architecture and impressive animation techniques. With this book, produce fun games with confidence.
Table of Contents (16 chapters)
Mastering Unity 5.x
Credits
About the Author
Acknowledgment
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Activating enemies and camera paths


We've now achieved a lot for the Dead keys game. We've created health, enemy AI, and the ability for enemies to change between different states. However, if we add enemies to the level right now, they'll begin in a sleeping or deactivated state and, as yet, nothing changes that state. To move forwards, we'll need to link the camera position in the level with enemies so that, as the camera moves near to an enemy, the enemy wakes up and becomes an active participant in the game. This allows us to pace our game with the camera. To achieve this, we'll use strategically positioned Trigger Volumes, with a GameTrigger script. The script is as follows:

//------------------------------------ 
using UnityEngine; 
using System.Collections; 
using UnityEngine.EventSystems; 
using UnityEngine.Events; 
//------------------------------------ 
public class GameTrigger : MonoBehaviour  
{ 
    public UnityEvent OnTriggerEntered; ...