Any City Generator · Documentation
Editing, JSON and Scripting
A road network is its layout: the nodes, the roads between them and each road's profile. Meshes, lanes and city blocks are rebuilt from it. This article covers editing a layout by hand, joining networks, the generator tab's other buttons, layout files in JSON, scripting with Python, and the lane, route and block queries your game can use.
← All Any City Generator documentation1 · The viewport
Drag points, then right-click for the rest
Select a network. Its nodes (amber) and control points (cyan) near the camera appear, with each road's curve drawn through them. Click a point and drag the gizmo; the network rebuilds when you release it.
▾ Right-click on a road or point
Points farther than Edit Point Draw Distance (60 m, under Project Settings > Plugins > Any City Generator > Road Editing) stay hidden, so fly close to the junction you want to edit. Alt-drag a control point to drag out a copy. A selected node where one or two roads meet shows tangent handles: drag one to turn the road through the node without moving it. Each move or menu action is one undo step.
Delete doesn't remove the network while you edit points. It deletes the selected point or node, or resets a selected tangent handle. To delete the whole network, click its road mesh first.
2 · The Details panel
Exact values in Network > Layout
The viewport shows no labels. For ids and exact values, select the network and open Details > Network > Layout. Every edit there rebuilds the preview.
▾ Network > Layout
Build Editor Preview Now under Details > Network builds at once; Rebuild Network builds on the next editor tick. Scale a network actor evenly, if at all: lane widths stay in profile units.
3 · Ports
Join two networks at their ports
A port is a node with Is Port and exactly one road: an open end another network can join. Traffic and routes cross once two ports meet within 100 cm and face each other, which is hard to hit by dragging. Bring the ports within Port Connect Distance (30 m), select the network that should move, then right-click its port node:
▾ Right-click on a port node
The other network never changes, and each entry is one undo step. Draw Ports (Details > Debug, on by default) shows an arrow at every port once the network has rebuilt: orange is open, green means every lane continues across, yellow only some, magenta none (usually two different profiles).
4 · The generator tab
Spawn, rebuild, export and import
Tools > Any City Generator > Any City Generator has more buttons than Generate City:
▾ Any City Generator
Import keeps the network's position and rotation, because layout locations are relative to the actor. The tab's status line shows the last result; when something fails, the reason is in the Output Log under LogAxCity (generation) or LogAxRoad (builds and files).
5 · JSON
Layouts as JSON files
A layout file holds one network's nodes, segments and road profiles. Locations, radii and widths are in centimetres, relative to the network actor; signal times are in seconds. Every file names its format: "AnyCityLayout", version 1.
▾ Top-level fields
{
"format": "AnyCityLayout",
"version": 1,
"drivingSide": "Right",
"profiles": { "local": "/AnyCityGenerator/Data/AnyRoad/Profiles/DA_Road_Local" },
"nodes": [
{ "id": 1, "location": [0, 0, 0], "port": true },
{ "id": 2, "location": [6000, 0, 0] }
],
"segments": [
{ "id": 1, "start": 1, "end": 2, "profile": "local", "controlPoints": [[3000, 1500, 0]] }
]
}
This is a curved local street with a port at node 1 and a turnaround bulb at node 2. Names such as Roundabout or TrafficSignal are not case-sensitive. Export writes every field, defaults included, and import keeps the ids. A file with a problem (wrong format or version, a missing field, an unknown name or profile) is logged to LogAxRoad, and the editor import then applies nothing.
Some problems only show in the build. A duplicate id, a missing node or a profile without a Driving lane still imports; the build logs each one and the network stays unbuilt.
6 · Scripting
Drive the plugin from Python or an AI agent
Every button except New Seed calls an editor library, so a script does what the tab does, with the same undo steps. Run Python from the editor console in Python mode, or as py "<file>.py" in Cmd mode. An AI agent connected to the editor through an MCP server that runs Python can call the same functions.
▾ unreal.AxCityEditorLibrary
import unreal
editor_library = unreal.AxCityEditorLibrary
# A small town 200 m along X, built before the call returns.
request = unreal.AxCityGenerationRequest()
request.preset = unreal.load_asset("/AnyCityGenerator/Data/AnyCity/Presets/DA_City_Town")
request.size = unreal.AxCitySize.SMALL
request.seed = 4711
request.origin = unreal.Vector(20000.0, 0.0, 0.0)
network = editor_library.generate_city_in_editor(request)
if network is None:
raise RuntimeError("Generation failed; see LogAxCity.")
# Blocks are relative to the network actor.
for block in network.get_blocks():
block_center = network.get_actor_transform().transform_location(block.centroid)
unreal.log("Block of {:.0f} m2 at {}".format(block.area / 10000.0, block_center))
# Export the layout to the project's Saved folder.
saved_dir = unreal.Paths.convert_relative_path_to_full(unreal.Paths.project_saved_dir())
editor_library.export_network_layout_to_file(network, saved_dir + "AnyCity_4711.json")
Editor calls build before they return, so a script can read blocks, lanes and ports straight away. Pass absolute file paths. Editor Utility Blueprints find the same functions under City Editor. unreal.AxOsmEditorLibrary runs the OpenStreetMap import the same way, and unreal.AxRoadLayoutJsonLibrary converts a layout to and from JSON text.
In a packaged game the editor library isn't there, but generation and import are runtime code. Spawn City Network builds a generated city, Generate City Layout returns the layout and its messages without spawning anything, and Import Osm File with Spawn Osm Networks builds an OpenStreetMap town. Each spawned network builds itself in BeginPlay.
7 · Lanes and routes
Lane and route queries for a GPS line or your own drivers
Every network builds a lane graph: each drivable path as a line of points, junctions included, linked to the lanes traffic continues into. The road network subsystem joins the lanes of all networks at their ports and answers these queries in the game, in Play In Editor and in the editor level. In Blueprint, get the subsystem with its getter node.
▾ Road network subsystem
#include "Subsystems/AxRoadNetworkSubsystem.h"
// A point every 10 m along the route from the player to a destination.
TArray<FVector> AMyPlayerController::BuildRoutePoints(FVector InDestination)
{
TArray<FVector> RoutePoints;
UAxRoadNetworkSubsystem* RoadSubsystem = GetWorld()->GetSubsystem<UAxRoadNetworkSubsystem>();
FAxLaneLocation StartLocation = RoadSubsystem->FindNearestLane(GetPawn()->GetActorLocation(), 1500.f, true);
FAxLaneLocation GoalLocation = RoadSubsystem->FindNearestLane(InDestination, 1500.f, true);
TArray<FAxLaneHandle> Route = RoadSubsystem->FindRoute(StartLocation.Lane, GoalLocation.Lane);
for (FAxLaneHandle& RouteLane : Route)
{
float LaneLength = RoadSubsystem->GetLaneLength(RouteLane);
for (float Distance = 0.f; Distance < LaneLength; Distance += 1000.f)
{
RoutePoints.Add(RoadSubsystem->GetLaneLocationAtDistance(RouteLane, Distance));
}
}
return RoutePoints;
}
Your game module needs AxRoad in its dependencies to call this from C++. The nearest lane may run the other way, so compare its Direction with the heading you want. Distances are measured in 3D, so a bridge and the street under it are told apart. To start exactly at the player and stop at the destination, cut the first and last lanes at the two Distance values.
Find the route again when the roads change. A rebuilt network invalidates its lane handles: listen to On Road Network Changed on the subsystem and rebuild the route.
8 · City blocks
City blocks for placing buildings
Generators leave the space between streets empty. Once a network is built (Is Network Built), Get Blocks on the network returns those spaces, already inset to the outer edge of the sidewalks and around curb corners and dead-end bulbs.
▾ Each block
Outline and Centroid are relative to the network actor: transform them with the actor's transform before you spawn anything, as the Python example above does. Highway, Ramp and (by default) elevated roads pass over blocks instead of bounding them, and blocks smaller than Min Block Area (40 m², under Details > Blocks) are dropped. Draw Blocks under Details > Debug draws every outline. An OpenStreetMap import brings no buildings, but Get Blocks still returns the spaces between its streets.
That's the whole system. Stuck, or after a road layout we haven't shown? Send us a message or an image of the city you want, and we'll help you build it.