using UnityEngine; using UnityEngine.AI; public class BlindMutantAI : MonoBehaviour { private NavMeshAgent agent; [Header("Настройки скорости")] public float walkSpeed = 2f; public float runSpeed = 5f; [Header("Патрулирование")] public Transform[] patrolPoints; private int currentPatrolIndex; private bool isInvestigating = false; void Start() { agent = GetComponent(); agent.speed = walkSpeed; if (patrolPoints.Length > 0) GoToNextPatrolPoint(); } void Update() { if (!agent.pathPending && agent.remainingDistance < 0.5f) { if (isInvestigating) { isInvestigating = false; agent.speed = walkSpeed; if (patrolPoints.Length > 0) GoToNextPatrolPoint(); } else if (patrolPoints.Length > 0) { GoToNextPatrolPoint(); } } } private void GoToNextPatrolPoint() { if (patrolPoints.Length == 0) return; agent.destination = patrolPoints[currentPatrolIndex].position; currentPatrolIndex = (currentPatrolIndex + 1) % patrolPoints.Length; } public void HearSound(Vector3 soundPosition) { isInvestigating = true; agent.speed = runSpeed; agent.SetDestination(soundPosition); } }