Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Hear(Vector3 soundLocation, float priority)
- {
- // Check if anti-hearing is inactive and the new sound priority is higher than the current one
- bool canHear = !this.antiHearing && priority >= this.currentPriority;
- Collider[] noSqueeAreaCheckers = Physics.OverlapSphere(soundLocation, 0.1f);
- foreach (Collider collider in noSqueeAreaCheckers)
- {
- if (collider.gameObject.CompareTag("NoSquee Area"))
- {
- canHear = false;
- }
- }
- if (canHear)
- {
- // Move to the sound location
- this.agent.SetDestination(soundLocation);
- // Update the current priority to the new sound's priority
- this.currentPriority = priority;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement