This commit is contained in:
2026-06-04 21:26:19 +07:00
parent b61b79c82e
commit 45d3fe8c21
10 changed files with 400 additions and 33 deletions

View File

@@ -122,6 +122,8 @@ public class EnemyAI : MonoBehaviour
private NodeState ActionPatrol()
{
// Debug.Log("Patrolling...");
if (!agent.isActiveAndEnabled || !agent.isOnNavMesh) return NodeState.Failure;
agent.isStopped = false; // Đảm bảo NPC được phép di chuyển
agent.speed = moveSpeed * 0.5f; // Đi dạo nên đi chậm lại một chút
@@ -156,6 +158,8 @@ public class EnemyAI : MonoBehaviour
// Debug.Log("Chasing Player");
if (!agent.isActiveAndEnabled || !agent.isOnNavMesh) return NodeState.Failure;
agent.isStopped = false;
agent.speed = moveSpeed; // Phục hồi tốc độ rượt đuổi
agent.SetDestination(player.position);
@@ -169,6 +173,8 @@ public class EnemyAI : MonoBehaviour
// Debug.Log("Focus and Shoot!");
if (!agent.isActiveAndEnabled || !agent.isOnNavMesh) return NodeState.Failure;
// Dừng NavMeshAgent lại để đứng bắn, tránh bị trượt
agent.isStopped = true;