There is an object (agent.gameObject) with a moving NavMesh Agent on a static floor object.
Navigation has already been baked.

The code below says "WhenMove ()is executed, this object moves up to 20m randomly on the x and z axes".

NavMeshAgent agent;
void Move () {
    Vector3 position = new Vector3 (gameObject.transform.position.x + Random.Range (-20, 20), 0.2f, gameObject.transform.position.z + Random.Range (-20, 20));
    NavMeshHit Hit;
    if (NavMesh.SamplePosition (position, out Hit, 1.0f, NavMesh.AllAreas))
     destination = position;
    if (agent.pathStatus! = NavMeshPathStatus.PathInvalid)
        agent.SetDestination (destination);
        Debug.Log ("NaMeshPath none");

Now when you runMove (), nothing happens.
I try to runSetDestination ()orDebug.Log ()near the end of the code, but nothing really happens.

Erasing the lastif (~~),else Debug.Log ()and leaving justSetDestination ()


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

The error

If i executeMove ()a dozen seconds after the start of debugging, nothing happens.
I'm not sure whyagent.pathStatus! = NavMeshPathStatus.PathInvalidis not true.

OrNavMesh.SamplePosition ()is going to correct the destination,
Is this wrong?

Please answer.