Question about RPG course

I am working through the RPG Core combat course,
in the main Attack / Fighter script in RPG.Combat, I have a LookAt(target.trasnform) method on the attack behavior.
The problem is that When the enemy dies, he keeps turning on the ground to follow my player.
I fixed the problem by checking in every Update method, whether or not the attacker is dead and only then attacking (referencing Health script in the Fighter Script.)

I know that this is No-no… But not sure how to solve this.
I know that this is not the best method, because it creates a circular dependency

What is the better way to approach this? Thank you

Actually, Health shouldn’t be depending on Fighter at all, meaning that it’s just fine for Fighter to check health. In fact, Fighter must depend on health so that it can inflict damage on the enemy’s health.

The best solution, however, is to have your EnemyController subscribe to the Health OnDie event. Then call ActionScheduler.CancelCurrentAction() in the method that subscribes to the event.

Ok, thank you!

Privacy & Terms