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
Thaks!