Set destination of a NavMeshAgent when instantiating

I’m trying to set the destination of an agent when it spawns, but, as I intanciate it, Unity returns this error:

114210-captura-de-pantalla-2018-04-03-a-las-184047.png

I’ve seen posts where people recommend using agent.Warp instead of transform.position, but I’m not even setting its position, because I’m spawning it from another object.

Good day Uri677 !

I supose you are instantiating the object, and then moving its position where you want.

When an object have a NAvMeshAgent, is better use this to change iots posotion:

Object.GetComponent<NavMeshAgent>().Warp(newPosition);

This way the object is placed over the NavMeshArea ready for setting its destination.

If helpped, please accept the answeer :smiley:

Bye !