O'Reilly logo

Building an RPG with Unity 5.x by Vahé Karamian

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

PC and NPC interaction

Thus far we have created the basic movement for both our PC and NPC. The next item I would like to complete is the attack mechanism for the PC and the NPC characters. Let's start by implementing the hit for the NPC.

Our NPC detects the player character based on the code we just created in the previous section. When the player character is in sight, the NPC will find the shortest path to the player character, and at a given range, it will attack the player character. So we have the movement and animation mechanics completed. The next objective is to keep track of the hit points when the NPC is attacking.

There are a few adjustments we need to make in the NPC_Animator_Controller. Open, the AnimatorWindow, and select the NPC_Attack ...

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