I have a terrain and NavMeshSurface that has been correctly baked.
I turned a script into a Coroutine with 5 seconds delay which spawns humans and puts them by raycasting on the ground.
I place Human on it, and I tell it SetDestination, then I get an error:
“SetDestination” can only be called on an active agent that has been placed on a NavMesh.
void Z()
{
Vector3 pos = transform.position;
if (Physics.Raycast(new Vector3(pos.x, 999, pos.z), Vector3.down, out RaycastHit hit, Mathf.Infinity, StaticX.layerMask))
{
transform.position = hit.point;
transform.GetComponent<MyHuman>().agent.SetDestination(Vector3.zero); // "SetDestination" can only be called on an active agent that has been placed on a NavMesh.
}
else
{
// Not invoked
}
}
The position is valid. Human GameObject hits the ground. Click the object paints the floor blue (as a validly baked mesh). I rebuilt it many times. What is possibly going wrong?
It’s placed on a valid mesh and the human has their NavMeshAgent enabled and put onto the object.