Rpg combat system tutorial for Unity with simple state machine – part 4

Rpg combat system tutorial for Unity with simple state machine – part 4

Share

Rpg combat system tutorial for Unity with simple state machine – part 4

In the previous Rpg combat system tutorial for Unity with simple state machine – part 3 we gave our player character a script to manage its combat states and to deal damage to the enemy, but to make it effective we need to give to the enemy a revised javascript enemyAi.js script to implement the functions called by the CombatSystem.js script by our player character. Edit the enemyAi script in the demon gameobject, it should look like the following :

[snippet id=100]

This rpg combat system tutorial for unity is almost ended, you can press play and test if the enemy and player health points are scaled correctly when they are in close combat and their Box triggers components intersect. This Rpg combat system for Unity with simple state machine is to be improved in the future, or by yourself, with two additional fixes. As of now it doesn’t matter if the attacker is facing the defender, so every gameobject that intersects with an attacker is hit and damaged regardless of the weapon orientation. Another quick fix its to make the player die if he runs out of health points and create a quick game over sequence!

12-Unity-rpg-hack-slash-combat-system-tutorial

I hope you enjoyed this Rpg combat system tutorial for Unity with simple state machine and that it gave you some ideas to make your combat system working !

You can find all the scripts used in this Unity rpg combat system tutorial with state machine in this page :

UNITY RPG COMBAT SYSTEM TUTORIAL WITH STATE MACHINE JAVASCRIPT FULL CODE DOWNLOAD EXAMPLES

 

 

Unity rpg combat system tutorial with state machine – part 1

Unity rpg combat system tutorial with state machine – part 2

Unity rpg combat system tutorial with state machine – part 3

1 thought on “Rpg combat system tutorial for Unity with simple state machine – part 4”

Leave a Comment