In my game, after loading in a scene and waiting 1s, I spawn enemies, using GetNearest() with a walkable constraint to try and avoid obstacles. I noticed recently that enemies can spawn inside buildings and in areas with a navmesh cut only in builds, not in the editor! Quite a surprise. How do I avoid this?
Edit: Upon further testing, for some reason, only in builds, my enemies love to run into the nearest wall they can find and stay magnetized towards it. I don’t remember it always being like this, I wonder if it’s an issue with the newer versions of unity? I’ll run some tests on older versions.
Edit 2: Tried testing earlier versions of Unity 6000.3, from the start of the year, and it also occurs there. Wonder how I messed things up this badly.
I’m guessing it’s something wrong with Astar. Using .GetNearest(), I always grab walkable points to spawn enemies in - but outside of the editor, in the build, enemies can still spawn inside non-walkable areas, or pathfind into them, causing them to run in place against their walls. I have no clue why this is happening, though.
I looked through the generation code, and as someone who doesn’t do mesh generation, I don’t know how you’d add it to your code- maybe just Mesh.isReadable?