New bugs introduced

I noticed this lecture broke a few things and makes it harder to implement some other future things (Like respawning enemies by just resetting values)

  1. Enemies keep aggravating themselves after they have been aggravated once.
  2. The timeSinceAggrevated will keep resetting itself so enemies will never switch to the suspicious state and will always chase you.

Any idea how to fix this without breaking the aggro system?

1 Like

The problem is that the enemy is aggrevating itself as well as it’s nearby friends. We want it to aggrevate it’s friends, but if it continously aggrevates itself, it will never get unaggroed.

Try adding a check to make sure that the ai!=this in the AggrevateNearbyEnemies:

        private void AggrevateNearbyEnemies()
        {
            RaycastHit[] hits = Physics.SphereCastAll(transform.position, shoutDistance, Vector3.up, 0);
            foreach (RaycastHit hit in hits)
            {
                AIController ai = hit.collider.GetComponent<AIController>();
                if ((ai == null) || (ai==this) ) continue;

                ai.Aggrevate();
            }
        }
4 Likes

Thanks for your reply Brian! I tried this before but it didn’t seem to work… However that was because I forgot to do a few other checks in my script. I’ve expanded the script quite a bit but thanks to your reply I tried it again made some other changes and everything works now! Fully functioning respawning enemies with customizable aggro properties.

Thanks again :blush:

If anyone is interested in how I got the enemies to respawn or anything else I described above feel free to reply here or send me a message.

2 Likes

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms