Loading...
Loading...
Guide for Unreal Engine 5.x PCG (Procedural Content Generation) Python integration. Covers the PCGPythonInterop plugin, the Execute Python Script node, PCG Python API (PCGComponent, PCGBlueprintElement, PCGSpatialData, PCGPointData), editor automation, custom PCG nodes via Python, and known limitations. Use when the user asks about PCG Python, PCGPythonInterop, Execute Python Script node, Python scripting for procedural generation, automating PCG graphs with Python, or creating custom PCG nodes with Python/Blueprint.
npx skill4agent add maystudios/claude-skills unreal-pcg-pythonunrealPCGComponentPCGBlueprintElement| Resource | URL |
|---|---|
| Forum: Create PCG Graph with Python | https://forums.unrealengine.com/t/create-pcg-graph-with-python/1714891 |
| Forum: Generate PCG through Python | https://forums.unrealengine.com/t/generate-pcg-through-python-script/2053107 |
| Forum: Change PCG Parameters from Python | https://forums.unrealengine.com/t/how-to-change-pcg-graph-parameters-from-python/2060532 |
| Custom PCG Nodes Guide (Blueshift) | https://blueshift-interactive.com/2025/09/03/how-to-create-custom-pcg-nodes/ |
| PCG Extended Toolkit (community C++ plugin) | https://github.com/PCGEx/PCGExtendedToolkit |
| Houdini to PCG Data Example | https://github.com/cgtoolbox/HoudiniToPCGDataExample |
Engine/Plugins/PCGInterops/PCGPythonInterop/IsBetaVersion: trueEnabledByDefault: falsePCGPythonInteropEditorPCGPythonScriptPlugin| Mode | Description |
|---|---|
| Reads Python source from an FString attribute on the "Source" pin, or uses an inline default script |
| Executes a |
bMuteEditorToastprint("Hello PCG World!")ScriptInputMethod -- EPCGPythonScriptInputMethod (Input or File)
ScriptSource -- FPCGAttributePropertyInputSelector (which attribute holds the script)
ScriptPath -- FFilePath (path to .py file, filtered to *.py)
bMuteEditorToast -- bool (suppress editor notification)PCG_OverridableEvaluateStatementimport unrealimport unreal
asset_tools = unreal.AssetToolsHelpers.get_asset_tools()
graph = asset_tools.create_asset(
'MyPCGGraph', '/Game/PCG',
unreal.PCGGraph, unreal.PCGGraphFactory()
)# Get PCGComponent from an actor
pcg_comp = actor.get_component_by_class(unreal.PCGComponent)
pcg_comp.generate(True) # force full regeneration
pcg_comp.generate_local(True) # local only, no replication
pcg_comp.set_graph(my_graph) # swap graph asset
pcg_comp.seed = 42 # set deterministic seed
pcg_comp.cleanup(True, False) # cleanup generated components# PCGSpatialData operations
spatial_data.to_point_data() # convert to points
spatial_data.intersect_with(other) # boolean intersection
spatial_data.union_with(other) # boolean union
spatial_data.subtract(other) # boolean subtraction
spatial_data.get_bounds() # get spatial bounds
spatial_data.get_density_at_position(pos) # sample density
# PCGPointData
point_data = unreal.PCGPointData()
points = point_data.get_points() # -> Array[PCGPoint]
point_data.set_points(modified_points)helpers = unreal.PCGBlueprintHelpers
helpers.get_actor_data(context)
helpers.get_component(context)
helpers.get_random_stream_from_point(point, settings, component)
helpers.compute_seed_from_position(position)
helpers.create_pcg_data_from_actor(actor, parse_actor)PCGBlueprintElement| Method | Purpose |
|---|---|
| Primary execution -- receives and returns |
| Execution with PCG context access |
| Per-point processing |
| Per-point, returns variable number of output points |
| Fixed-count iteration |
| Custom display name |
| Custom node color |
element.custom_input_pins # Array[PCGPinProperties]
element.custom_output_pins # Array[PCGPinProperties]
element.has_default_in_pin # bool
element.has_default_out_pin # bool
element.is_cacheable # bool
element.requires_game_thread # bool| Limitation | Details |
|---|---|
| Editor-only | No Python in packaged builds or runtime. The node explicitly errors: "Editor-only, should not be used at runtime." |
| No programmatic node creation | Python cannot add/connect nodes within a PCG graph programmatically (Epic confirmed, as of 2024) |
| No data output from Execute Python Script | The node only provides execution ordering, not PCG data flow |
| Main thread only | Python execution blocks the main thread |
| API churn | Method names changed between 5.2-5.5 (e.g., |
| Parameter access is finicky | Setting PCG graph parameters from Python via |
| UE Version | PCG Status | Python Notes |
|---|---|---|
| 5.2 | Experimental | |
| 5.3 | Experimental | |
| 5.4 | Beta | |
| 5.5 | Beta | GPU compute path, |
| 5.7 | Production-Ready | |