PCG basics
Have an agent scatter meshes across a landscape with Unreal's Procedural Content Generation framework, read back how many instances it placed, then edit the graph node by node.
Before you start
- Hayba is installed and your agent is connected. See Getting started.
- The level has a Landscape. The scatter samples a Landscape surface; a static mesh floor gives zero points. Make one in Landscape mode, or have the agent import a heightmap with
world_ingest. - Review each external edit is off. This guide creates a graph and a volume, which the exact review cannot approve on this version. See What can be approved.
Prompt
Scatter /Engine/BasicShapes/Cone across the landscape at 0.05 points per square metre, with random yaw and scale between 0.8 and 1.4. Tell me how many instances were placed. Then list the generated graph's nodes, lower the density to 0.02, regenerate, and give me the new count.
What the agent does
pcg_scatter_meshbuilds a jittered PCG graph, places a PCG volume bound to it, generates, and returns the instance count. It fails loudly on zero instances.hayba_export_pcg_graphreturns the graph as JSON: its nodes, settings and edges.pcg_set_propchanges the sampler's density. Nested settings use/paths.pcg_cook_and_waitregenerates the volume, waits for the graph to settle and returns the instance count per mesh.
Trust the counts from pcg_cook_and_wait. PCG generates asynchronously, so a plain
generate reads zero in the same call, and pcg_read_node_output reads a cache that
may be stale.
Editing the graph
To build or change a graph by hand rather than with the one-call scatter:
hayba_search_node_catalogfinds a node by what it does, when the class name is not known.pcg_add_nodeadds a node by its settings class. New nodes land at the origin of the graph.pcg_list_pinslists a node's exact pin labels. Labels are not obvious: the graph input's output pin isIn.pcg_wireconnects two pins. It checks the pin names first and never drops a wire silently.pcg_layoutarranges the nodes left to right. Close and reopen the graph editor tab to see the new positions.pcg_get_nodereads one node's settings in full, andhayba_introspectlists the properties of a settings class.
To remove things, pcg_disconnect cuts one
edge and pcg_remove_node deletes a node
and its edges. Node indices shift after a removal, so the agent re-reads the graph before the
next edit.
Check the result
- Ask for
pcg_inspect_instanceson the volume to read the counts again without regenerating. - Have the agent frame the volume and capture the viewport. See Place actors and capture the viewport.
- Open the generated graph asset in the PCG editor.