I thought I’d cracked the NPC nav thing, but no.
In Flourishing, critters collect collectible GOs that are sitting on the ground. They approach a collectible, pick it up, and carry it to a magic collection well. Then they go get another one. Repeat forever. When a collectible is dropped into the well it vanishes, then reappears where it started after a minute or so.
Critters get stuck on obstacles like rocks. Some get to the GO they’re supposed to grab, but stop near them, without interacting. Only sometimes, though, and only large critters (I think). Critters sometimes get stuck trying to pass each other, but not usually.
Gaah!
After a long session with Gemini, I have some rules that might work consistently. I don’t understand them fully, but hopefully enough.
As usual, I don’t know what I’m doing, so use at your own risk.
The rules relate six values for each of the nine wandering critter types in Flourishing:
- The radius of the critter’s capsule collider.
- The navmesh baking radius for that critter type.
- The navmesh agent’s avoidance radius.
- The collection distance, how close the NPC gets to the collectible before it gets collected.
- The navmesh agent’s avoidance priority.
- The navmesh agent’s avoidance quality.
I stop NPCs in code rather than having the critter’s navmesh agent stop its quest. Should be the same. I hope.
There is one more set of values that has to do with the collectibles, the game objects my critters are supposed to collect. There are barrels, books, buckets, and other things. More later.
Rule 1. Set avoidance quality to high. A little more CPU load, though not much. Hopefully, unless there are hundreds of critters.
Rule 2. Vary avoidance priority to reduce the trying-to-get-around-each-other-in-a-hallway dance, where critters move the same distance to each side when trying to avoid each other.
I gave larger creatures more priority. Strangely, that means giving them lower values in the navmesh agent’s avoidance priority field, according to the manual. Most important = 0. Least important = 99. Default = 50. Agents with lower numbers will force agents with higher numbers to move out of the way.
Rule 3. Capsule collider radius < avoidance radius ≤ baking radius. Gemini said the avoidance radius and the baking radius should be equal to get the best results. It also said: The general “sweet spot” used by most Unity developers is to make the Capsule Collider radius about 10% to 20% smaller than the NavMesh Agent’s Avoidance Radius.
Rule 4: Collection distance ≥ critter capsule collider radius + collectible collider radius.
There are many collectibles, so many collectible collider radii. The values for collectibles that don’t use capsule colliders (box or mesh colliders) will have to be estimated.
Rule 5. Base navmesh surface geometry on physics colliders, not render meshes.

There’s a tradeoff here. Suppose the ground’s render mesh has some bumps, like pebbles. Using meshes for geometry will put the pebbles in the navmesh. That’s good, since NPC behavior will match the ground exactly. It’s bad, since the navmesh will be noisy. The NPC might get stuck on the pebbles. I’ve had strange gaps in some navmeshes; they might be caused by using the render meshes for navmesh baking.
Another thing I wondered about was critters with irregular shapes are aren’t encompassed well by a single collider. Like this beast:

The body could have a capsule collider fitted to it fairly well, but that would leave out the wings and tail. They could clip through things. So, give them their own colliders, resulting in a compound collider.
That would work for the physics system, but the nav system is its own thing. Navmesh agents use just one circle for each creature. Suppose a tail collider stuck outside the navmesh radius. The navmesh agent could send the beast to a point, then turn it around. The beast’s tail could get snagged on something. The physics and nav systems would fight for control.
I could make the navmesh circle big enough to encompass everything. The problem there is the beast is too large to move between trees. Well, it could, but the navmesh agent won’t see paths between trees as valid.
Gaaah!
Gemini’s simplest solution was to have one collider over the torso, with the navmesh circle large enough to encompass it. Clippy clippy, though.
Gaaah!
Actually… I’ve just talked myself into dropping the dragon from the game. And the other large irregular critter, a big hermit crab. I’ll replace them with critters that are easier to set up.
OK, where are we? I want six numeric values for each NPC:
- Capsule radius
- Avoidance radius
- Baking radius
- Collection distance
- Avoidance priority
- Avoidance quality
Avoidance quality is always set to high quality. Another variable mentioned above, navmesh surface geometry, is always set to physics colliders for this game.
Capsule radius is set by the geometry of the 3D mesh. Avoidance and baking radii are computed based on the capsule. No extra data required.
Avoidance priority is an ordinal value, not a ratio one. The order can depend on capsule radius as well. It should be based on mass rather than collider capsule radius, but they should be correlated, so this is close enough.
About collection distance. Each NPC can have a unique collection distance. However, there are many collectibles. The code could compute a unique collection distance for each collectible for each critter. I might end up doing that, but for now, I’ll just use the same collection distance for all the collectibles.
The value depends on the collection circle radii of the collectibles. The collection circle is a circle centered on the object that encompasses the object, or most of it for an irregular one. I want the largest collection circle radius across the object set, ideally. There was one object that was about twice as long as wide. It had a large collection circle that was mostly MT. I got rid of it because I’m a nervous nelly. Across the set, it seems like a collection distance of 0.6m should work.
Here’s what I came up with:
| Capsule radius | Avoidance radius | Baking radius | Avoidance priority | Collection distance | |
| Bloom | 0.8 | 0.92 | 0.92 | 10 | 1.4 |
| Bud | 0.3 | 0.35 | 0.35 | 50 | 0.9 |
| Dragon spark | 0.5 | 0.58 | 0.58 | 25 | 1.1 |
| Shell | 0.4 | 0.46 | 0.46 | 35 | 1 |
| Spike | 0.8 | 0.92 | 0.92 | 15 | 1.4 |
| Sun blossom | 0.4 | 0.46 | 0.46 | 40 | 1 |
| Sunflower fairy | 0.35 | 0.4 | 0.4 | 45 | 0.95 |
| Sunflora pixie | 0.5 | 0.58 | 0.58 | 30 | 1.1 |
| Wolf pup | 0.6 | 0.7 | 0.7 | 20 | 1.2 |
Ack! I hope this works.