Wall Generation

Walls are how you tell the crowd where it cannot go. Internally the simulation keeps a wall grid: a coarse grid of square tiles (size = WallTileSize) that are either open or blocked. Blocked tiles both block pathfinding (routes go around them) and, when bWallCollision is on, physically stop agents from entering.

Seeding walls from the nav mesh

The easiest way to get walls that match your level is to mirror Unreal's navigation mesh. The crowd actor's Wall Generation Method defaults to Nav Mesh, so the walls are built automatically on BeginPlay.

Wall Generation Method set to Nav Mesh
Wall Generation Method set to Nav Mesh

What happens: the built nav mesh is rasterized into the wall grid - every WallTileSize cell whose centre is not covered by a navigable triangle becomes a wall. So holes, static obstacles and unnavigable regions in the nav mesh become walls in the crowd sim.

Generated wall tiles over the level
Generated wall tiles over the level

Staying in sync at runtime

With Sync Walls With Nav Mesh on (the default), the walls update automatically whenever the nav mesh rebuilds at runtime - this requires Runtime Generation = Dynamic on the RecastNavMesh. Tiles you stamped manually with AddWallTile are never touched.

GenerateWallTilesFromNavMesh() runs the same sync on demand.

Generate Wall Tiles From Nav Mesh node
Generate Wall Tiles From Nav Mesh node
int32 Changed = Crowd->GenerateWallTilesFromNavMesh();

Stamping and removing walls at runtime

You can also add and remove wall tiles directly, by grid coordinate, without any nav mesh - e.g. stamp a building's footprint when it's placed and remove it when it's destroyed.

Add Wall Tile node
Add Wall Tile node
// Block the tile at grid (X, Y). Coordinates are in wall-tile units.
Crowd->AddWallTile(10, 4);

// Unblock it again (e.g. the building was destroyed):
Crowd->RemoveWallTile(10, 4);

// Drop the whole grid, or read it back (e.g. to visualise it):
Crowd->ClearWallTiles();
TArray<FIntPoint> Tiles = Crowd->GetWallTiles();

Any wall change - added or removed - invalidates the affected pathfinding caches, so existing orders re-route on the following ticks.

Tuning how the crowd treats walls

Property Effect
Has Collision (bWallCollision) Master switch for physical wall blocking. Off = walls still block pathfinding but agents can pass through them.
Tile Size (WallTileSize) World units per wall tile. Smaller = obstacles represented more precisely, more tiles.
Near Wall Cost (NearWallCost) Pathfinding traversal multiplier for open cells touching a wall. Higher pushes routes away from walls (agents hug corners less). 1 disables the bias.

See the Crowd Actor reference for the full property list.