Failed to create agent because it is not close enough to the NavMesh & "SetDestination" can only be called on an active agent that has been placed on a NavMesh.

All the answers I found for the similar problems doesn’t fix my headache :frowning:

In my project what I’m trying to do is instantiate lots of worm based on a worm already in the world, and the worm has some simple AI so they can move randomly around. There is an object pooler to recycle the worms so they can be generated again in front of person, and whenever it is called again to be shown at the new position, it has a chance to popup those errors and warning (while some of them are just doing fine).

This is the simple object pool I’ve got:

private void Start()
        items = new List<GameObject>();

        //add all the objects to the worm mesh pool
        for(int i = 0;i<amount; i++)
            GameObject obj = Instantiate(itemSpawn);

            //deactive the object for the start

        InvokeRepeating("Spawns", frequncy, frequncy);

void Spawns()   //active the object from the worm pool
        //get player position
        pos = player.transform.position;
        for (int i = 0; i < items.Count; i++)
            if (!items*.activeInHierarchy)*

//generate a random position in front of the player on the plane
Vector3 position = new Vector3(Random.Range(-5F, 5F),
Random.Range(0.5F, 3.50F),
Random.Range(0.0F, 30.0F) + pos.z+0.5f);
items*.transform.Rotate(0,(Random.Range(-90F, 90F)),0);*
*I tried to add download the navmesh component form*_
which helps me none. Also checked the position where the worms are generated, since I set the navmesh surface be really free, big and high, I don’t think that this problem is caused by the agent not on surface.
Changing on the prefab is also not helpful.
Those worms are instantiated form the same gameobject which is already in the world, when the one triggered the problem it won’t move as much as its own kind. These doesn’t effect much on the game now, but keep getting these errors, I think it’s better to be fixed.
Hope someone could give me a hand on what is going on…_

Good day.

You are not warping coreectly, you forget to close the getcomponent, look what ypu have :smiley:


< > so is not executing that line, so you are not warping it.

:smiley: Byee