So this is my code for spawning an AI car. I am using Warp() to avoid the “not detecting navmesh” error. However, when it spawns I get the error “SetDestination can only be called on an active agent that has been placed on a NavMesh”. As you may see, I’ve tried to place it, but it doesen’t seem to work. Any idea?
You could just spawn it at hit.position, as that’s on the navmesh. Then you don’t have to warp it.
I’ve tried out, but I keep getting the same error
Also, I’ve tried a lot of suggestions of other threads similar to this one
Hi @ics_de … same issue here. Did you find a solution?
Nope, just left aside the project
Hey, so I’ve been progressing in ohter projects and found out that this doesn’t happen if your game / NavMeshAgents aren’t too small!
Wow thanks a lot for this information !
I just spent like 4 hours on a bug in my project, monsters randomly not spawning where they should -.-
In the end i used NavMeshAgent.warp instead of directly modifying the transform.position.
And before using the warp, i modify the agent radius to a bigger one (0.5f in my case), and then switch it back to the actual value after the successful warp :o
Don’t know why there is so little information about this “bug” (i guess it is), i did not find anything though you saved what ever is left of my night :,D
Thanks again
You’re welcome! I actually stumble upon this problem every single time I use navmeshes, so save a link to this thread or smth for future use!
I hope Unity work on it cuz it’s really unintuitive to solve, tbh.
I also changed the radius to 0.5f but I am getting the same error
I have been stuck on this issue since 4 dyas while I was doi g other things plz suggest
Hey!
Who doesn’t have NavMeshAgent.Warp()
Note that NavMeshAgent should be initialized in the Awake() method, not Start().
This ensures that all components will be initialized before any other logic is executed that starts with Start() or even earlier, such as in the OnEnable() methods.
This is important because the initialization of enemies may depend on the state of the NavMeshAgent, for example, to move correctly to the starting point.