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.
TIP
The wall grid is independent of the pathfinding tile grid.
WallTileSize controls how finely obstacles are represented; PathTileSize controls routing
resolution.
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.
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.
This requires the nav mesh to be built. Add a Nav Mesh Bounds Volume to your level (and
a RecastNavMesh actor) covering the playable area, the same as you would for normal UE
navigation.
By default only enclosed unwalkable areas (holes and obstacles surrounded by walkable mesh)
become walls - the outer edge of the nav mesh stays open. Enable
bGenerateNavMeshBorderWalls to also wall off the region along the nav mesh's outer border
(plus a one-tile fence past its rim), sealing agents inside the navigable area.
Regenerating at runtime
GenerateWallTilesFromNavMesh() is callable directly, so you can rebuild walls at any time
(e.g. after rebuilding the nav mesh) regardless of the Wall Generation Method setting. It
returns the number of wall tiles added and is safe to call repeatedly - adding a tile that
already exists is a no-op.
int32 Added = Crowd->GenerateWallTilesFromNavMesh();
Stamping walls at runtime
You can also add wall tiles directly, by grid coordinate, without any nav mesh. This is the building block for "place a building, the crowd reroutes around it": convert the building's footprint to tile coordinates and stamp those tiles.
// Block the tile at grid (X, Y). Coordinates are in wall-tile units.
Crowd->AddWallTile(10, 4);
// Read back every wall tile (e.g. to visualise the grid):
TArray<FIntPoint> Tiles = Crowd->GetWallTiles();
Newly added walls invalidate the affected pathfinding caches, so existing orders re-route on the next move.
Wall removal and an actor-driven obstacle component are on the roadmap (v1.x). In 1.0, walls are added, not removed - to clear them, reset the simulation and re-seed.
Tuning how the crowd treats walls
See the Crowd Actor reference for the full property list.