Creating a queuing function for AI

Hi,

I am trying to think of how to create a way for my enemies to queue up when they are near the player, and wait their turn to interact with the player. A video of my AI not queuing is below:

I was thinking of code such as:

void OnTriggerEnter (Collider other)
{
if (other.GameObject.CompareTag("Player") && if(other.gameObject.CompareTag("Enemy")
{
NavMeshAgent.Stop();
//And change the walk animation a sub state machine with random idle animations
}
}

Do you have any suggestions on how you would try (or have) created a way for the AI to queue up to my player?
As my example code suggests, I am thinking of using OnTriggerEnter, but I am looking for some feedback.

Thanks

Another way I think I could solve my issue would be to check if an object in its collider is using an attack animation, and if they are to stop the Nav Mesh; but I’m not sure how this clause would be written down.

Here is an article on a battle circle maybe some helpful hints.

2 Likes