0

I'm using NavmeshAgent to make the enemy chase the player. Below is my script

public Transform goal;
private NavMeshAgent agent;
private bool playerInSightRange;
private bool playerInAttackRange;
private void Awake()
{
    agent = GetComponent<NavMeshAgent>();
}

private void FixedUpdate()
{
    ChasePlayer();
}

private void ChasePlayer()
{
    Debug.Log(agent.SetDestination(goal.position));
}

However, the enemy is not moving unless my player arrives at a certain location, beside the fridge to be specific. I'm really confused right now and any help would be appreciated. I have attached my navmesh map below. Thank you!

Person holding the sword is the enemy

Jerry
  • 21
  • 1
  • 6

1 Answers1

0

I somehow solved the issue by changing the destination y value to be the y value of the navmesh agent.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Jerry
  • 21
  • 1
  • 6