How to make only one enemy attack player at a time in unity

Viewed 52

In my Scene i have three enemies spawned at a point when player comes in their range they start attacking but the problem is all three enemies are attacking player at the same time. I want that when an enemy attack player other 2 must wait until first one is finished or enemy attack player alternatively

1 Answers

One way is to assigning a boolean to the player, isUnderAttack. When an enemy tries to engage the player, check if the player is under attack, if it is true, stop the attack, if false, go ahead and attack. You can define any type of behavior for queued enemies.

Related