Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Unity Character Animation with Mecanim

You're reading from   Unity Character Animation with Mecanim A detailed guide to the complex new animation tools in Unity, packed with clear instructions and illustrated with original content in the context of a next generation zombie apocalypse adventure game

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher
ISBN-13 9781849696364
Length 290 pages
Edition 1st Edition
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Jamie Dean Jamie Dean
Author Profile Icon Jamie Dean
Jamie Dean
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. The Zombie Attacks! 2. Rigging Characters for Unity in 3ds Max and Maya FREE CHAPTER 3. Interacting with the Environment 4. Working with Motion Capture Data 5. Retargeting Animation 6. Talking Heads 7. Controlling Player Animation with Blend Trees 8. Implementing Ragdoll Physics 9. Controlling Enemy Animation with AI and Triggers Index

Adding code to the zombie_ready script

The script currently attached to the female zombie, adequately handles its current states: Idle and Walk. We need to add a few lines of code to the script to trigger the face animation:

  1. In the Project panel, scroll down until the PACKT_Scripts folder is visible.
  2. Double-click on it to make its contents visible in the Assets panel.
  3. Locate zombie_ready and double-click on it to open the script in MonoDevelop.

We will start by adding a few variables. At the top of the script, add the following lines of code:

var target : Transform;
var alerted : boolean = false;
var snarlSound : AudioClip;
var soundReady : boolean = true;

The target variable will store the player character's position. The next variable, alerted is a boolean. It is basically an on/off switch that will allow the zombie to go into a new routine.

The next two variables deal with the sound that we will be using to make it clear that the zombie has been alerted.

The snarlSound variable is an audio...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image