Skip to content

Procedural

11 tools for PCG graphs, their parameters and components, generating and reading the generated data.

Back to the index.

add_pcg_component

Additive Idempotent

Attach a PCG component (the procedural generation engine) to an editor-world actor, found by name or label, and optionally point it at a PCG graph -- what turns a plain actor or volume into something that scatters meshes and points by rule. Over add_component_to_actor it assigns the graph via UPCGComponent::SetGraph, which set_properties cannot (the graph lives in a read-only GraphInstance). Idempotent: an actor that already has one (an APCGVolume does) gets it back, graph re-assigned. It generates within the actor's BOUNDS, so a volume with no brush geometry yields zero instances with no error -- check get_actor_bounds first. Then generate_pcg_component and get_pcg_component_info. Not saved.

Parameter Type Required Description
actor_name string yes Display label or internal name of the target editor-world actor (required)
pcg_graph_path string no Optional /Game/... path of a UPCGGraph to assign to the component

Returns: { actor_name, component_name, already_existed, graph_path, graph_assigned }

add_pcg_graph_parameter

Additive Idempotent

Expose a tunable on a PCG graph (bool / int / float / double / string) so density, radius or a toggle can be driven from outside instead of being welded into a node. Idempotent (already_existed when the name is taken). Only worth doing on graphs you own -- adding one to a library graph means editing that asset. Set a value with set_pcg_graph_parameter and list them with get_pcg_graph_parameters; inverse: remove_pcg_graph_parameter.

Parameter Type Required Description
pcg_graph_path string yes /Game/... path to the UPCGGraph (required)
name string yes Parameter name (required)
type string yes "bool" | "int" | "float" | "double" | "string" (required); int32 and integer are accepted too.

Returns: { pcg_graph_path, name, type, added, already_existed, parameter_count }

cleanup_pcg_component

Destructive

Wipe a PCG component's generated output synchronously -- and the step you must not skip after editing a graph: a plain generate_pcg_component with force reuses the CACHED result, so the world keeps the STALE meshes and settings while every flag reads generated:true. Call this with remove_components=true FIRST, then generate, then verify by re-reading the actor's spawned components rather than the generated flag. Also the way to clear procedural content before moving or resizing the volume.

Parameter Type Required Description
actor_name string yes Actor holding the UPCGComponent (required)
remove_components boolean no Optional; also remove spawned managed components (default false)

Returns: { actor_name, cleaned, generated }

create_pcg_graph

Additive Idempotent

Create an empty UPCGGraph asset at package_path/name and save it, or return the UPCGGraph already there unchanged (created=false, already_exists=true, nothing saved), so repeat calls are idempotent. A fresh graph holds only its implicit Input and Output nodes, which node_count leaves out (0). Another asset class at that path, or an invalid path, is an error; a failed save, as during PIE, makes success false with save_error. No undo step is recorded. Requires the PCG plugin. Next: add nodes with add_graph_node (types from list_pcg_node_types), wire them with connect_pins, expose tunables with add_pcg_graph_parameter, read back with get_graph_nodes, and use it in the level through spawn_box_volume or add_pcg_component.

Parameter Type Required Description
name string yes Name of the PCG Graph asset to create; the object path becomes package_path/name.name.
package_path string no Destination /Game folder (default /Game/PCG); a trailing slash is ignored.

Returns: { graph_name: string, asset_path: string, created: bool, already_exists?: bool, node_count: int, saved?: bool, save_error?: string }

generate_pcg_component

Additive

Triggers PCG generation on an actor's UPCGComponent. Generation is ASYNCHRONOUS (scheduled on the PCG subsystem, resolved over subsequent editor ticks) — this returns the scheduled task id, NOT a finished result. Poll get_pcg_component_info / get_pcg_generated_data for completion (honest).

Parameter Type Required Description
actor_name string yes Actor holding the UPCGComponent (required)
force boolean no Optional; force regeneration even if already generated (default true)

Returns: { actor_name, scheduled, task_id, is_generating, generated, note }

get_pcg_component_info

Read-only

Read an actor's PCG component: which graph it runs, its seed, whether it is generating or already generated, activated, partitioned, and its generation trigger. Read-only. Use it to find which graph is driving an actor and to confirm a seed for deterministic scatter -- but NOT as proof the world matches the graph: generated:true is satisfied by a cached result, so after editing a graph the flag says done while the spawned meshes are stale. The real check is the actor's spawned components (get_pcg_generated_data / get_components_by_class), after cleanup_pcg_component + generate_pcg_component.

Parameter Type Required Description
actor_name string yes Actor holding the UPCGComponent (required)

Returns: { actor_name, has_component, graph_path, is_generating, generated, seed, activated, is_partitioned, generation_trigger }

get_pcg_generated_data

Read-only

Report what the PCG component of an editor-world actor produced in its last generation, without changing anything: per output item its pin, tags and data class (e.g. PCGPointData). Generation is asynchronous, so the list is empty, with a note, until a generate_pcg_component run has completed: poll this or get_pcg_component_info after triggering it. An actor without a PCG component answers has_component false and an empty list rather than an error; an actor that is not found is an error. For the component's graph, seed and generating state use get_pcg_component_info; for the graph's nodes get_graph_nodes; to clear the output cleanup_pcg_component.

Parameter Type Required Description
actor_name string yes Actor holding the PCG component (an APCGVolume or an actor given one by add_pcg_component), by object name or editor label, e.g. "PCGVolume_0" (required)

Returns: { actor_name, has_component, output_data_count, data:[{index, pin, data_class, tags:[...]}], note? }

get_pcg_graph_parameters

Read-only

List a PCG graph's user parameters with name, type and current value -- and the read that decides whether a THIRD-PARTY graph can be reused without editing it. An empty list means nothing is exposed: meshes, densities and exclusions are welded inside, so the only way to change them is to edit the asset, which is not an option for a read-only library graph. Read-only. Note it accepts a PCGGraph asset, not a PCGGraphInstance -- overriding a parameter on an instance has no headless route and must be ticked in the details panel.

Parameter Type Required Description
pcg_graph_path string yes /Game/... path to the UPCGGraph (required)

Returns: { pcg_graph_path, parameter_count, parameters:[{name, type, value}] }

list_pcg_node_types

Read-only

Enumerate every PCG node type available in this build (all concrete PCGSettings subclasses, including plugin- and project-added ones), with class names and paths, sorted by name and paged with offset/limit. Run it before add_graph_node so you pass a class that exists instead of guessing a name from documentation that may not match this engine version. Read-only reflection.

Parameter Type Required Description
offset integer no Index of the first entry returned, counted from 0 (default 0). Read the next page at the reply's next_offset.
limit integer no Most entries returned per call, 1..1000 (default 100).

Returns: { base_class, count (entries in this page), types:[{name, path}], total: int, offset: int, limit: int, returned: int, truncated: bool, next_offset: int|null }

remove_pcg_graph_parameter

Destructive

Remove a user parameter from a PCG graph asset, in one undo step, and delete the Get Parameter nodes that read it, as the PCG editor does when a parameter goes (getter_nodes_removed); the graph is marked dirty, not saved, as add_pcg_graph_parameter leaves it. Inverse of add_pcg_graph_parameter. A name the graph has no parameter for is an honest no-op (removed=false); a graph that does not load is an error (a PCGGraphInstance is not accepted, as for set_pcg_graph_parameter). The reply re-reads the parameters (parameters). Generated output is not refreshed: cleanup_pcg_component then generate_pcg_component. Read: get_pcg_graph_parameters.

Parameter Type Required Description
pcg_graph_path string yes /Game/... path to the UPCGGraph (required)
name string yes Parameter name to remove (required)

Returns: { pcg_graph_path, name, removed, getter_nodes_removed, parameter_count, parameters: [string], note? }

set_pcg_graph_parameter

Destructive Idempotent

Write the value of an existing PCG graph user parameter (bool / int / float / double) and read the stored value back, so the reply is its own oracle -- how you tune scatter density or a rule threshold without opening the graph. The parameter must already exist (add_pcg_graph_parameter) and the value type must match. IMPORTANT: it accepts a PCGGraph ASSET only and answers "PCG graph not found" for a PCGGraphInstance -- per-instance overrides have no headless route and must be ticked in the details panel. Changing a parameter does not update the world: cleanup_pcg_component then generate_pcg_component, or the cached output is reused.

Parameter Type Required Description
pcg_graph_path string yes /Game/... path to the UPCGGraph (required)
name string yes Parameter name (must already exist; add with add_pcg_graph_parameter) (required)
value string no New value; its type must match the parameter's declared type (required)

Returns: { pcg_graph_path, name, type, set, value }