Advertisement
Guest User

a

a guest
Aug 22nd, 2024
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. public void Hear(Vector3 soundLocation, float priority)
  2. {
  3. // Check if anti-hearing is inactive and the new sound priority is higher than the current one
  4. bool canHear = !this.antiHearing && priority >= this.currentPriority;
  5. Collider[] noSqueeAreaCheckers = Physics.OverlapSphere(soundLocation, 0.1f);
  6. foreach (Collider collider in noSqueeAreaCheckers)
  7. {
  8. if (collider.gameObject.CompareTag("NoSquee Area"))
  9. {
  10. canHear = false;
  11. }
  12. }
  13. if (canHear)
  14. {
  15. // Move to the sound location
  16. this.agent.SetDestination(soundLocation);
  17.  
  18. // Update the current priority to the new sound's priority
  19. this.currentPriority = priority;
  20.  
  21.  
  22. }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement