I suspect it has to be a problem with the area mask bit of sampleposition. If I set it to 1 or ~Navmesh.GetAreaByName(“Walkable”) the “Rats” will spawn as I intend. What’s wrong with my sampleposition? Does getareabyname return the wrong bit or something?
The area mask on the rats navmeshagent is also set to “Walkable”
if (NavMesh.SamplePosition(transform.position, out hit, 2f, NavMesh.GetAreaByName("Walkable")))
{
GameObject rat = Instantiate(rats, hit.position, Quaternion.identity);
Thank you, it was the bitshifting, I had tried this earlier and it wasn’t working but I believe I probably had my navmeshsurface wrong as well at that time. It’s working good now, thank you!