update
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user