NPC Animation

Animator

The easiest way to create animation for an NPC is to have the character execute a single animation state like idle, created by dragging a set of sprites into the scene view. In order to create more interesting animation, a custom script needs to be added to the NPC as shown below.

NPC Animation: Animator, Coroutine, Button

The following is a simple script that use a co-routine to have the NPC have a delayed switch between 2 animator states. Configure the Animator states as you did with the Player, however in this case, use "NPCState" as the name of the animator integer parameter that controls the transitions between animation states. The public methods allow for changing the state of the NPC from some other object such as a UI-Button as shown in the image below.

A button's onClick event is configured to call SetIdle for the Zombie gameObject

Last updated