то же самое
This commit is contained in:
1 parent
090cdc9933
commit
ac99977be3
534 files changed
+36990
-48
No files matched your search
@@ -1,7 +1,55 @@
|
||||
namespace DefaultNamespace
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
public class BlindMutantAI : MonoBehaviour
|
||||
{
|
||||
public class BlindMutantAI
|
||||
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<NavMeshAgent>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user