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

Developing the Dead state


After the zombie enters the Death state within the animator graph, it remains there and cannot revert to any other state. The animator graph simply suspends, without linking to any new state:

Death state

The code is therefore pretty simple:

    //------------------------------------ 
    public IEnumerator StateDead() 
    { 
        //Run dead animation 
        ThisAnimator.SetInteger("AnimState", (int) ActiveState); 
 
        //While in idle state 
        while(ActiveState == AISTATE.DEAD) 
        { 
             yield return null; 
        } 
    } 
    //------------------------------------