"SetDestination" can only be called on an active agent that has been placed on a NavMesh

So I’m making a 3d fps game. I was using @Brackeys tutorial - ENEMY AI - Making an RPG in Unity (E10) - YouTube just to add enemy. I checked my script 2 times, It’s the same as in the video, i did all things correctly and got this error. I tried to press Window>Navigation and change some settings but it did not help me.
Maybe this tutorial is not for 3D game, but i think it is. I’ll be really thankful if someone will help.
Thanks, here’s my script
public float lookRadius = 10f;

Transform target;
NavMeshAgent agent;

// Use this for initialization
void Start () {
    target = PlayerMAnager.instance.player.transform;
    agent = GetComponent<NavMeshAgent>();
}

// Update is called once per frame
void Update () {
    float distance = Vector3.Distance(target.position, transform.position);

    if (distance <= lookRadius)
    {
        agent.SetDestination(target.position);

        if (distance <= agent.stoppingDistance)
        {
            FaceTarget();
        }
    }
}

void FaceTarget()
{
    Vector3 direction = (target.position - transform.position).normalized;
    Quaternion lookRotation = (Quaternion.LookRotation(new Vector3(direction.x, 0, direction.z)));
    transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * 5f);
}

private void OnDrawGizmosSelected()
{
    Gizmos.color = Color.red;
    Gizmos.DrawWireSphere(transform.position, lookRadius);
}

}

Unity’s Navmesh system is built for 3D games, so you’re good.
Two possible things that I see could be going wrong are:

  1. You haven’t baked a Navigation Mesh to the scene. This link should help if that’s the case Unity - Manual: Building a NavMesh
  2. You must either programmatically place the character on the Navmesh using a raycast or something, or simply drag the character close to the Navmesh.
    I hope this helps!

Well, you can go to Window > AI > Navigation and then configure which objects you want to be in the NavMesh (they have to be static). Then you can go to the Bake section of the tab, and click “Bake”. Another thing is that make sure you place your player and enemies over the NavMesh. If they aren’t, it will (probably) throw an error.