ふくふくHukuhuku Inc.
EP.04LLM Gamedev 12分公開: 2026-05-26

Unreal Engine 5 × LLM ── C++ 生成と Blueprint の隙間を埋める

Unreal Engine 5 と LLM の組合せ。C++ コード生成の実用度、Blueprint (ビジュアルスクリプト) を LLM でどう扱うか、MetaHuman / Nanite / Lumen 等のフォトリアル機能と LLM の連携。

#Unreal Engine#UE5#C++#Blueprint#MetaHuman
執筆 / 監修
松尾 亮合同会社ふくふく 代表社員

データ基盤・データパイプライン構築 / BI / 生成 AI 活用支援を専門とするエンジニア (28 年)。 本記事は AI 利用ポリシーに基づき、生成 AI の補助で執筆 → 人間が監修・編集して公開しています。

プロフィール詳細
シェア

EP.02 (), EP.03 () と続いて、本 EP は 5 × 連動度は ★3 と前 2 者に劣りますが、フォトリアル 3D / コンソール対応 / 大規模配信を考えると候補に入る選択肢。 とのハイブリッド設計が鍵。

1. Unreal で LLM が活躍する場所

対象LLM 連動度備考
C++ コードAActor / UComponent / Subsystem のボイラープレート生成が特に効く
Editor Utility Scripts (Python)アセット一括処理、ビルド自動化
Material Editorノードベース GUI、LLM 直接編集不可
Blueprintビジュアルスクリプト、生成は困難
Niagara (VFX)ノードベース、パラメータ提案までは可
Sequencer (シネマティック)Python API 経由で操作可能

2. C++ コード生成の典型例 (AActor)

MyPawn.h
Code
#pragma once
#include "CoreMinimal.h"#include "GameFramework/Pawn.h"#include "MyPawn.generated.h"
UCLASS()class MYGAME_API AMyPawn : public APawn{    GENERATED_BODY()
public:    AMyPawn();
    UPROPERTY(EditAnywhere, Category = "Movement")    float Speed = 600.0f;
protected:    virtual void BeginPlay() override;    virtual void Tick(float DeltaTime) override;    virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override;
private:    void MoveForward(float Value);    void MoveRight(float Value);
    UPROPERTY(VisibleAnywhere, Category = "Components")    UStaticMeshComponent* MeshComponent;};
MyPawn.cpp
Code
#include "MyPawn.h"#include "Components/InputComponent.h"
AMyPawn::AMyPawn(){    PrimaryActorTick.bCanEverTick = true;
    MeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComponent"));    RootComponent = MeshComponent;}
void AMyPawn::BeginPlay(){    Super::BeginPlay();}
void AMyPawn::Tick(float DeltaTime){    Super::Tick(DeltaTime);}
void AMyPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent){    Super::SetupPlayerInputComponent(PlayerInputComponent);    PlayerInputComponent->BindAxis("MoveForward", this, &AMyPawn::MoveForward);    PlayerInputComponent->BindAxis("MoveRight", this, &AMyPawn::MoveRight);}
void AMyPawn::MoveForward(float Value){    AddActorLocalOffset(FVector(Value * Speed * GetWorld()->GetDeltaSeconds(), 0, 0));}
void AMyPawn::MoveRight(float Value){    AddActorLocalOffset(FVector(0, Value * Speed * GetWorld()->GetDeltaSeconds(), 0));}
Enhanced Input System (UE 5.1+)

UE 5.1 から Input System が刷新された。`PlayerInputComponent->BindAxis` は旧 API。新規プロジェクトは `Enhanced Input` (Input Action / Input Mapping Context) を使う。Claude に「UE5.3 で Enhanced Input を使って」 と指示すれば対応してくれる。

3. Editor Utility Scripts (Python)

Unreal は Editor 内で Python が動く。アセット一括処理 / ビルド自動化 / テスト実行などを Claude に書かせて、Editor 経由で実行できる。

全 StaticMesh に LOD を追加する Editor スクリプト
Python
import unreal
@unreal.uclass()class AutoLODGenerator(unreal.Object):
    @unreal.ufunction(callable=True)    def add_lods_to_all_meshes(self, asset_path: str = "/Game/Meshes"):        asset_registry = unreal.AssetRegistryHelpers.get_asset_registry()        assets = asset_registry.get_assets_by_path(asset_path, recursive=True)
        for asset_data in assets:            asset = asset_data.get_asset()            if isinstance(asset, unreal.StaticMesh):                # LOD0 から 50% / 25% / 12% のスクリーンサイズ閾値で LOD 追加                unreal.EditorStaticMeshLibrary.set_lods(asset,                    unreal.EditorScriptingMeshReductionOptions(                        auto_compute_lod_screen_size=False,                        reduction_settings=[                            unreal.EditorScriptingMeshReductionSettings(percent_triangles=0.5),                            unreal.EditorScriptingMeshReductionSettings(percent_triangles=0.25),                            unreal.EditorScriptingMeshReductionSettings(percent_triangles=0.12),                        ]                    ))                unreal.log(f"Added LODs to {asset.get_name()}")
# 実行: Editor → Window → Output Log → コンソールで:# AutoLODGenerator().add_lods_to_all_meshes("/Game/Meshes")

4. Blueprint との付き合い方

  • Blueprint で組んだロジックを Claude が C++ に書き起こす: スクリーンショットを貼って「これを C++ で同等に」
  • 逆 (C++ → Blueprint) は不可、Editor で手動
  • C++ Component + Blueprint Wrapper: 主要ロジックを C++、レベル固有のチューニングを Blueprint
  • Blueprint to Text Plugin (Marketplace) で Blueprint を可読テキスト化 → LLM が読める

5. MetaHuman + LLM の組合せ

  • MetaHuman Creator で人物アセット作成 (顔・髪・衣装を Web ベースで)
  • LLM で台詞・性格設定 → MetaHuman Audio-Driven Animation で口パク自動
  • OpenAI Realtime API / Anthropic で対話、ElevenLabs で音声化、MetaHuman で表示 → AI NPC
  • 注意: フォトリアル人物 + LLM 対話は「Uncanny Valley」を起こしやすい、用途設計が重要

6. Nanite / Lumen と LLM

Nanite (仮想化ジオメトリ)Lumen (リアルタイム GI) は UE5 の目玉機能。LLM の役割は限定的 (パラメータ調整推奨くらい) だが、「Lumen のチラつきを抑えたい、設定どうする」 のような質問には Claude が UE5 ドキュメント情報をベースに答えられる。

7. ビルド・パッケージ自動化

UAT (Unreal Automation Tool) でパッケージング
Bash
# Mac/Linux 例./Engine/Build/BatchFiles/RunUAT.sh BuildCookRun \  -project="/path/to/MyGame.uproject" \  -platform=Mac \  -configuration=Shipping \  -cook -allmaps -build -stage -pak -archive \  -archivedirectory="/path/to/Output"
# Windows./Engine/Build/BatchFiles/RunUAT.bat BuildCookRun \  -project="C:\Path\MyGame.uproject" \  -platform=Win64 -configuration=Shipping \  -cook -allmaps -build -stage -pak -archive \  -archivedirectory="C:\Output"

8. ハマりどころ

問題対処
UCLASS / UPROPERTY マクロ忘れリフレクション効かず Blueprint から見えない
GENERATED_BODY() 漏れコンパイルエラー、コピペ忘れ
Hot Reload 不安定Live Coding 推奨、駄目なら Editor 再起動
GC で UObject 消えるUPROPERTY() で保持、TWeakObjectPtr で参照
Header 循環依存Forward declaration + .cpp での include
Engine バージョンアップでビルド壊れる.uproject の EngineAssociation を慎重に変更

9. 次の話

EP.05 は pygame で学ぶ LLM 開発の全工程 ── 一番シンプルな環境で、仕様策定 → 実装 → 配布まで Claude と一緒に進めるサンプル。教育・プロトタイプの定番。

シェア

この記事の感想を教えてください

あなたの 1 クリックで、本当にこの記事は更新されます。「もっと詳しく」「続編希望」が一定数集まった記事は、 ふくふくが 実際に内容を拡充したり続編記事を公開 します。 送信したリアクションはお使いのブラウザに記録され、再カウントされません。

シリーズの外も探す:

まずは、現状を聞かせてください。

要件が固まっていなくて大丈夫です。現状診断と方針提案までを無料でお手伝いします。

無料相談フォームへ hello [at] hukuhuku [dot] co [dot] jp