Navmesh becomes UNwalkable when I instantiate

Hello!

Ive been trying to fix this issue for a day now and Im stuck. When I instantiate ai prefab, area turns unwalkable for some reason.

This is the error Im getting: “SetDestination” can only be called on an active agent that has been placed on a NavMesh.

This is how I spawn:

 public void spawnGhost()
    {
        NavMeshHit hit;
        if (NavMesh.SamplePosition(spawnPoint.transform.position, out hit, 100f, NavMesh.AllAreas))
        {
             PhotonNetwork.InstantiateRoomObject(selectedGhostString, hit.position, Quaternion.identity);
        }
    }

After that I even check if agent is on the navmesh:

private void Start()
    {
        if (!ghostAgent.isOnNavMesh)
            resetNavmeshAgent();

        ChangeState(idleState);
    }

    private void resetNavmeshAgent()
    {
        Debug.Log("Reseting navmesh agent");
        NavMeshHit hit;
        NavMesh.SamplePosition(spawnPoint, out hit, 100f, NavMesh.AllAreas);
        Vector3 warpPosition = hit.position;
        ghostAgent.transform.position = warpPosition;
        ghostAgent.enabled = false;
        ghostAgent.enabled = true;
    }

Help please :frowning:
Thaks!

Okay managed to fix it. Area becomes dark blue when agent is in that area. Somehow the referance I put in prefab does not count as referance and needed to get component at runtime and disable-reenable the agent worked that way. Weird but okay.