AI で Unreal Engine のブループリントを扱う
ブループリントは多くの Unreal プロジェクトの骨格で、その作業の多くは組み立てです。適切な親クラス、いくつかのコンポーネント、妥当なデフォルト値を持つ変数、コンパイル、配置。Unreal MCP Pro はこれらの手順を AI に任せられるようにします。このガイドでは順番に説明し、まだできない部分もはっきり書きます。
できること・できないこと
- できる: 任意の親クラスからのブループリントクラス作成、コンポーネント追加、デフォルト値付きの変数追加、クラスデフォルトの設定、コンパイル、構造の読み取り、インスタンスの配置。ウィジェット・アニメーション・Gameplay Ability・Gameplay Effect のブループリント作成。
- まだできない: イベントグラフや関数の編集(ブループリントグラフのノード作成や接続はなし)。
set_widget_bindingも 1.0.3 では動作しません。
1. クラスを作る
create_blueprint { "name": "BP_Pickup", "path": "/Game/Blueprints", "parent_class": "Actor" }
parent_class の既定は Actor です。Pawn、Character、GameModeBase、PlayerController、自作の C++ クラスも同じように使えます。
2. コンポーネントを追加
add_blueprint_component { "blueprint": "/Game/Blueprints/BP_Pickup", "component_class": "StaticMeshComponent", "component_name": "Mesh" }
add_blueprint_component { "blueprint": "/Game/Blueprints/BP_Pickup", "component_class": "SphereComponent", "component_name": "Trigger" }
add_blueprint_component { "blueprint": "/Game/Blueprints/BP_Pickup", "component_class": "PointLightComponent", "component_name": "Glow" }
3. 変数とデフォルト値
create_blueprint_variable { "blueprint": "/Game/Blueprints/BP_Pickup", "name": "Points", "type": "Int" }
create_blueprint_variable { "blueprint": "/Game/Blueprints/BP_Pickup", "name": "bRespawns", "type": "Bool" }
compile_blueprint { "blueprint": "/Game/Blueprints/BP_Pickup" }
set_blueprint_default { "blueprint": "/Game/Blueprints/BP_Pickup", "property": "Points", "value": "10" }
set_blueprint_default { "blueprint": "/Game/Blueprints/BP_Pickup", "property": "bRespawns", "value": "true" }
set_blueprint_default はクラスデフォルト(CDO)のプロパティを設定します。新しい変数はコンパイル後に初めて生成クラスに現れるので、先にコンパイルしてください。
1.0.3 の既知の制限: create_blueprint_variable の default_value 引数は反映されません(上のように set_blueprint_default を使います)。また Float と Vector の変数は UE5 が必要とするサブタイプなしで作られるので、ブループリントエディタで確認してください。Bool・Int・String・Name・Text は単純な型です。メッシュなどのコンポーネント設定は、配置したインスタンスに set_component_property で設定するか、execute_python を使うのが簡単です。
4. コンパイルと確認
compile_blueprint でコンパイルしてエラーを報告し、get_blueprint_info で親クラス・コンポーネント・変数を返すので、AI は次に進む前に結果を確かめられます。
5. レベルに配置
spawn_actor には生成クラス名(例: BP_Pickup_C)を渡します。ブループリントが読み込まれている必要がありますが、作成・コンパイルした直後なら読み込まれています。そのあとインスタンスに list_components と set_component_property(例えばメッシュ)を、たくさん置くなら batch_spawn_actors を使います。
ロジックをどこに書くか
1.0.3 ではグラフを編集しないので、作業を分けます。クラス・コンポーネント・変数・デフォルト値は AI に作らせ、イベントグラフは自分でつなぎます(構造ができていれば数ノードで済むことが多いです)。あるいは振る舞いを C++ に置く方法もあります。Claude Code のような AI クライアントは自身のファイル操作でプロジェクトに C++ クラスを書けるので、ブループリントは parent_class でそれを継承するだけにできます。
ウィジェットブループリント(UMG)
create_widget_blueprint { "name": "WBP_HUD", "path": "/Game/UI" }
add_widget_child { "widget": "/Game/UI/WBP_HUD", "child_class": "CanvasPanel", "name": "Root" }
add_widget_child { "widget": "/Game/UI/WBP_HUD", "child_class": "TextBlock", "name": "ScoreText" }
set_widget_property { "widget": "/Game/UI/WBP_HUD", "target": "ScoreText", "property": "text", "value": "Score: 0" }
get_widget_info { "widget": "/Game/UI/WBP_HUD" }
バインディング(set_widget_binding)はグラフ関数が必要なので 1.0.3 では作成されません。ウィジェットデザイナーで設定してください。
アニメーションブループリント
スケルトンに対する create_anim_blueprint、アクターのスケルタルメッシュコンポーネントに割り当てる set_anim_blueprint、周辺アセット用の create_blend_space と create_anim_montage。AnimGraph 自体はエディタで編集します。
プロンプトの例
/Game/Blueprints に BP_Pickup(親は Actor)を作って。StaticMeshComponent "Mesh"、
SphereComponent "Trigger"、PointLightComponent "Glow" を追加。Int 変数 Points(既定値 10)と
Bool 変数 bRespawns(既定値 true)も追加。コンパイルして get_blueprint_info を見せて。
そのあと PlayerStart の前に 3 m 間隔で 3 つ配置し、メッシュを
/Engine/BasicShapes/Sphere.Sphere にして。
Unreal MCP Pro を入手
itch.io で $5 の買い切り、アップデート無料。