| 123456789101112131415161718 |
- using UnityEngine;
- /// <summary>
- /// Trigger volume placed in exit rooms to detect when agents reach the goal.
- /// When an agent enters the trigger, it calls StopAtGoal() to stop movement and mark as exited.
- /// </summary>
- public class ExitRoomTrigger : MonoBehaviour
- {
- private void OnTriggerEnter(Collider other)
- {
- // Check if the entering object is an agent
- AIAgent agent = other.GetComponent<AIAgent>();
- if (agent != null && !agent.HasReachedGoal)
- {
- agent.StopAtGoal();
- }
- }
- }
|