ExitRoomTrigger.cs 544 B

123456789101112131415161718
  1. using UnityEngine;
  2. /// <summary>
  3. /// Trigger volume placed in exit rooms to detect when agents reach the goal.
  4. /// When an agent enters the trigger, it calls StopAtGoal() to stop movement and mark as exited.
  5. /// </summary>
  6. public class ExitRoomTrigger : MonoBehaviour
  7. {
  8. private void OnTriggerEnter(Collider other)
  9. {
  10. // Check if the entering object is an agent
  11. AIAgent agent = other.GetComponent<AIAgent>();
  12. if (agent != null && !agent.HasReachedGoal)
  13. {
  14. agent.StopAtGoal();
  15. }
  16. }
  17. }