O'Reilly logo

Mastering Unity 5.x by Alan Thorn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Developing the Attack state and more

The Attack state is entered when the zombie arrives within the attack distance to the player. During this state, the zombie repeatedly attacks the player until either the player dies or the player leaves the attack distance:

Developing the Attack state and more

Attack state

Consider the following code:

 //------------------------------------ public IEnumerator StateAttack() { //Run attack animation ThisAnimator.SetInteger("AnimState", (int) ActiveState); //While in idle state while(ActiveState == AISTATE.ATTACK) { //Look at player Vector3 PlanarPosition = new Vector3(PlayerTransform.position.x, ThisTransform.position.y, PlayerTransform.position.z); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required