Ue Cpp Fundamentalsのロゴ

Ue Cpp Fundamentals

コミュニティ
kevinpbuckley
ue-cpp-fundamentals

Write correct Unreal Engine C++ using the UObject reflection system — UCLASS/USTRUCT/ UENUM/UINTERFACE macros, UPROPERTY and UFUNCTION specifiers, GENERATED_BODY, the *.generated.h pipeline, class prefixes (U/A/F/E/I), module API export macros, the Class Default Object (CDO), NewObject vs CreateDefaultSubobject, garbage-collection-safe ownership, and UClass vs UScriptStruct internals. Use when authoring or editing any UE C++ class, exposing members or functions to Blueprints or replication, fixing UHT/reflection build errors, or choosing between pointer and ownership types.

概要

公開者kevinpbuckley
リポジトリunreal-engine-skills
スキル名ue-cpp-fundamentals
スター
89
フォーク
9
同梱ファイル
3
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 3個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    kevinpbuckleyがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Ue Cpp Fundamentals」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/kevinpbuckley/unreal-engine-skills/tree/master/skills/core/ue-cpp-fundamentals
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/kevinpbuckley/unreal-engine-skills.git /tmp/unreal-engine-skills
mkdir -p .claude/skills
cp -r /tmp/unreal-engine-skills/skills/core/ue-cpp-fundamentals .claude/skills/ue-cpp-fundamentals
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでUe Cpp Fundamentalsを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にUe Cpp Fundamentalsを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Ue Cpp Fundamentalsは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Unreal Engine C++ fundamentals

Unreal C++ is standard C++ augmented by a reflection layer generated by the Unreal Header Tool (UHT). Getting the reflection macros right determines whether your code compiles, appears in Blueprints, replicates correctly, and survives garbage collection.

When to use this skill

  • Creating or editing any U*/A* class or F* struct in C++.
  • Exposing a member or function to Blueprints, the editor, or network replication.
  • Diagnosing UHT errors ("Unrecognized type", "missing generated.h", "GENERATED_BODY missing").
  • Deciding between TObjectPtr, raw pointer, TWeakObjectPtr, or TSharedPtr.
  • Understanding how the CDO works or why a constructor runs in the editor.

Mental model

Three interlocking pieces:

  1. UObject is the base of the reflected, garbage-collected object graph. Every class that opts into the system derives from it (directly or via AActor, UActorComponent, etc.).
  2. UHT parses your headers before the compiler and emits a <ClassName>.generated.h that contains boilerplate for reflection, serialization, and Blueprint integration. You include this file last and place GENERATED_BODY() inside the type.
  3. UClass (the runtime type descriptor) holds a Class Default Object (CDO) — one instance constructed at startup with all defaults applied. New instances copy from the CDO. The constructor runs on the CDO and in the editor; never put gameplay logic there.

UObjects are garbage-collected. Any UObject* you want kept alive must be stored in a UPROPERTY. A plain C++ pointer is invisible to the GC and will dangle after the next collection.

Class prefixes (mandatory)

PrefixMeaningExamples
UUObject-derived (non-Actor)UActorComponent, UMyDataAsset
AActor-derived (world-placeable)AActor, AMyCharacter
FPlain struct / non-UObject value typeFVector, FMyConfig
EEnumEMyState
IInterface (the IFoo half of a UFoo/IFoo pair)IInteractable
TTemplateTArray, TObjectPtr
SSlate widgetSButton

The class name after the prefix must match the filename (minus prefix): AMyPawn lives in MyPawn.h / MyPawn.cpp.

Anatomy of a UObject class

cpp
// MyActor.h
#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"   // ALWAYS LAST include

UCLASS(Blueprintable, BlueprintType)
class MYGAME_API AMyActor : public AActor   // MYGAME_API = module export macro
{
    GENERATED_BODY()

public:
    AMyActor();

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats")
    float Health = 100.f;

    UFUNCTION(BlueprintCallable, Category = "Stats")
    void ApplyDamage(float Amount);

protected:
    virtual void BeginPlay() override;

    UPROPERTY(VisibleAnywhere)
    TObjectPtr<USceneComponent> Root;   // UPROPERTY keeps it alive in the GC graph
};
cpp
// MyActor.cpp
#include "MyActor.h"

AMyActor::AMyActor()
{
    PrimaryActorTick.bCanEverTick = true;
    Root = CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
    SetRootComponent(Root);
}

void AMyActor::BeginPlay()
{
    Super::BeginPlay();   // call Super on all engine virtual overrides
}

void AMyActor::ApplyDamage(float Amount)
{
    Health = FMath::Max(0.f, Health - Amount);
}

Four rules that prevent most build breaks:

  • #include "X.generated.h" is the last include in the header.
  • Every reflected class/struct has GENERATED_BODY().
  • The class is annotated with the module API macro (MYGAME_API) so other modules can link it.
  • Always call Super:: in overridden engine virtuals (BeginPlay, Tick, EndPlay, …).

UCLASS specifiers

Verified in ObjectMacros.h (namespace UC, line 792):

  • Blueprintable — the class can be subclassed in Blueprint.
  • BlueprintType — can be used as a Blueprint variable type.
  • Abstract — cannot be instantiated directly.
  • Config=Game — properties marked Config are read/written from *.ini files.
  • MinimalAPI — exports only the reflection boilerplate (Cast<>, etc.); use in leaf-module classes to reduce link surface.
  • meta=(PrioritizeCategories="Stats") — editor ordering hints.

UPROPERTY specifiers

Verified in ObjectMacros.h (namespace UP, line 1046):

Edit / visibility (Details panel):

  • EditAnywhere — editable on CDO and placed instances.
  • EditDefaultsOnly — CDO (Blueprint defaults) only.
  • EditInstanceOnly — placed instances only.
  • VisibleAnywhere / VisibleDefaultsOnly / VisibleInstanceOnly — read-only in the editor.

Blueprint access:

  • BlueprintReadWrite — get and set in BP. BlueprintReadOnly — get only.

Common combos and meta:

  • Category = "Group" — organizes the Details panel (required for every exposed member).
  • meta=(ClampMin="0", ClampMax="100") — value ranges.
  • meta=(AllowPrivateAccess="true") — expose a private member to Blueprint.
  • Transient — not saved to disk. SaveGame — included in SaveGame serialization.
  • Replicated / ReplicatedUsing=OnRep_Func — network replication (see ue-networking-and-replication).
  • Instanced — for per-instance configurable subobjects.

Memory rule: any UObject* member you want kept alive must be a UPROPERTY. Use TObjectPtr<UType> for class members (editor-aware, access-tracked in UE5); raw UType* is acceptable for local variables and function parameters. Without UPROPERTY, the GC can collect the object and leave a dangling pointer. See ue-memory-and-gc for the full pointer hierarchy.

UFUNCTION specifiers

Verified in ObjectMacros.h (namespace UF, line 945):

  • BlueprintCallable — callable from Blueprint event graphs.
  • BlueprintPure — no side effects; pure node (no exec pins).
  • BlueprintImplementableEvent — declared in C++, fully implemented in Blueprint; no C++ body.
  • BlueprintNativeEvent — C++ default (Func_Implementation) overridable in Blueprint.
  • CallInEditor — adds a button in the Details panel for editor-time execution.
  • Exec — registers as a console command.
  • Server / Client / NetMulticast + Reliable/Unreliable — RPCs.

BlueprintNativeEvent pattern:

cpp
UFUNCTION(BlueprintNativeEvent, Category="AI")
void OnSpotted(AActor* By);
void OnSpotted_Implementation(AActor* By);   // C++ default, override in BP

USTRUCT, UENUM, UINTERFACE

cpp
// Value type struct — no GC, stack/value semantics
USTRUCT(BlueprintType)
struct FLoadout
{
    GENERATED_BODY()
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Loadout")
    int32 Ammo = 0;
};

// Enum — uint8-backed required for Blueprint use
UENUM(BlueprintType)
enum class EDoorState : uint8 { Closed, Opening, Open, Closing };

// Interface: always declare both halves (U* is the UObject shell; I* is the C++ interface)
UINTERFACE(MinimalAPI, Blueprintable)
class UInteractable : public UInterface { GENERATED_BODY() };

class IInteractable
{
    GENERATED_BODY()
public:
    UFUNCTION(BlueprintNativeEvent, Category="Interaction")
    void Interact(AActor* Instigator);
};

Key differences between USTRUCT and UCLASS:

  • UScriptStruct (the runtime descriptor for USTRUCT) derives from UStruct, not UClass. Struct instances are value types — no GC, no CDO, no NewObject.
  • UPROPERTY inside a struct still enables serialization and editor exposure; it does not imply GC ownership (there is nothing for the GC to track in a value type).
  • Prefer USTRUCT for lightweight data bags (stats, configs, hit results). Use UCLASS when you need GC lifetime, Blueprint subclassing, or per-instance identity.

See references/reflection-macros.md for the full specifier reference with less-common options.

Object construction

APIWhenNotes
CreateDefaultSubobject<T>(TEXT("Name"))Constructor onlyCreates owned subobject; names must be unique per class
NewObject<T>(Outer)Runtime, non-ActorUse for any UObject that is not an Actor
GetWorld()->SpawnActor<T>(Class, FTransform)Runtime, ActorsSee ue-actors-and-components
Cast<T>(Obj)AnywhereSafe checked cast; returns null on failure — never static_cast
IsValid(Obj)AnywhereTrue if non-null and not garbage; prefer over bare null check

CreateDefaultSubobject is declared on UObject (Object.h:151). NewObject template overloads are in UObjectGlobals.h (lines 1931, 1959, 1974).

The CDO is created by UClass::GetDefaultObject (Class.h:4519) the first time it is needed. After construction the CDO is read-only; modify only through archetype/default propagation.

Full construction paths, CDO lifecycle, and PostInitProperties are in references/uobject-lifecycle-and-cdo.md.

Pointer and ownership cheat sheet

NeedUse
UObject member you own / keep aliveUPROPERTY() TObjectPtr<UType>
Local variable or function parameterraw UType*
Non-owning ref that may be destroyedTWeakObjectPtr<UType> — check .IsValid() before use
Non-UObject heap object, shared ownershipTSharedPtr<T> / TSharedRef<T>
Asset reference loaded on demandTSoftObjectPtr<T> / TSoftClassPtr<T>

TObjectPtr<T> (declared in ObjectPtr.h:519) is the modern form for UPROPERTY members in UE5. Older code uses raw T* UPROPERTY() pointers, which still compile and work. Legacy code you encounter will mix both styles.

Gotchas

  • Forgot UPROPERTY on a UObject member* → random crashes after GC. The most common bug.
  • generated.h not last / missing GENERATED_BODY() → cryptic UHT errors that appear unrelated to the actual mistake.
  • Gameplay logic in the constructor → runs on the CDO and in the editor; no world, no gameplay. Always put gameplay init in BeginPlay.
  • CreateDefaultSubobject outside the constructor → asserts (detected by FObjectInitializer::AssertIfInConstructor, UObjectGlobals.h:1936).
  • NewObject with an empty name inside a constructor → also asserts; use CreateDefaultSubobject instead.
  • Calling editor-only API from runtime code → packaging failures; guard with #if WITH_EDITOR.
  • UENUM not backed by uint8 → Blueprint-unusable; BlueprintType enum must be uint8.
  • ClassDefaultObject accessed directly → deprecated as of UE 5.6; use GetDefaultObject()/GetDefault<T>() instead (Class.h:4045).
  • FName/FString/FText mix-ups → see ue-core-types-and-containers.

Version notes

  • TObjectPtr<T> (UPROPERTY member idiom) and TObjectPtr-backed GC barrier were introduced in UE5. Pre-5.0 code uses raw T* UPROPERTY(), which still works but lacks editor access tracking.
  • MarkPendingKill() was replaced by MarkAsGarbage() in UE5; with gc.PendingKillEnabled=false (the new default), the GC no longer auto-nulls pointers — use IsValid() and clear references in EndPlay/callbacks.
  • ClassDefaultObject was deprecated as a direct field access in 5.6; use GetDefaultObject().

References & source material

Engine source (UE 5.8, under Engine/Source/Runtime/CoreUObject/Public/UObject/):

  • Object.h:98 — UObject class definition; :151 — CreateDefaultSubobject; :226 — PostInitProperties; :361 — BeginDestroy; :368 — IsReadyForFinishDestroy; :382 — FinishDestroy; :1886 — IsValid().
  • ObjectMacros.h:778 — UPROPERTY/UFUNCTION/USTRUCT/UENUM macro stubs; :800 — GENERATED_BODY; :832 — UCLASS specifiers; :985 — UFUNCTION specifiers; :1086 — UPROPERTY specifiers; :1216 — USTRUCT specifiers.
  • Class.h:495 — UStruct; :1774 — UScriptStruct; :3893 — UClass; :4045 — deprecated ClassDefaultObject field (5.6+); :4519 — GetDefaultObject().
  • UObjectGlobals.h:1931 — NewObject<T>(Outer, Class, Name, …); :1959 — NewObject<T>(Outer) (no name); :1974 — NewObject<T>(Outer, Name, …).
  • ObjectPtr.h:519 — TObjectPtr<T>.
  • Interface.h:18 — UInterface base class.

Official docs (UE 5.8):

Deep-dive references in this skill:

Cross-reference sibling skills:

  • ue-memory-and-gc — deep dive on pointer types, weak pointers, GC tuning.
  • ue-actors-and-components — Actor/component lifecycle, spawning, ticking.
  • ue-blueprint-cpp-integration — exposing C++ types to Blueprint in depth.
  • ue-module-and-build-system — the module API macro, Build.cs, UHT pipeline details.

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Ue Cpp Fundamentals」では何ができますか?

Write correct Unreal Engine C++ using the UObject reflection system — UCLASS/USTRUCT/ UENUM/UINTERFACE macros, UPROPERTY and UFUNCTION specifiers, GENERATED_BODY, the *.generated.h pipeline, class prefixes (U/A/F/E/I), module API export macros, the Class Default Object (CDO), NewObject vs CreateDefaultSubobject, garbage-collection-safe ownership, and UClass vs UScriptStruct internals. Use when authoring or editing any UE C++ class, exposing members or functions to Blueprints or replication, fixing UHT/reflection build errors, or choosing between pointer and ownership types.

TypingMindでUe Cpp Fundamentalsを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Ue Cpp Fundamentalsはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにUe Cpp Fundamentalsをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/kevinpbuckley/unreal-engine-skills/tree/master/skills/core/ue-cpp-fundamentalsを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Ue Cpp Fundamentalsを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Ue Cpp Fundamentalsで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもUe Cpp Fundamentalsを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Ue Cpp Fundamentals」は無料ですか?

kevinpbuckleyがGitHubで公開しています。ライセンス条件はリポジトリでご確認ください。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇