본문으로 건너뛰기
Skillpedia
일반 코딩6.6k · #13854

unreal-cpp-gameplay

하는 일

이 스킬은 Unreal Engine 5용 C++ 게임플레이 코드를 작성하고 이를 에디터에 연결하는 방법을 설명합니다. C++로 게임 시스템을 만드는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓Unreal Engine 5에서 C++ 액터, 폰, 캐릭터, 컴포넌트를 만들 때.
  • ✓C++ 속성이나 함수를 에디터나 Blueprint에 보여 줘야 할 때.
  • ✓Build.cs 파일에 모듈 의존성이 빠져 있을 때.

스킬 링크

https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/unreal/unreal-cpp-gameplay/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/unreal/unreal-cpp-gameplay/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“디자이너가 에디터에서 설정할 수 있도록 내 Unreal 캐릭터용 C++ 체력 컴포넌트를 작성해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

이름 접두사 규칙, 데이터를 에디터에 노출하는 리플렉션 매크로, 주요 프레임워크 클래스의 역할, 모듈 의존성 목록 작성 방법을 설명합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Unreal C++ Gameplay

Write correct UE5 gameplay C++: the reflection macros that connect C++ to the editor and Blueprints, the Gameplay Framework class roles, and module dependencies. Targets UE 5.8.

When to use

  • Use when creating C++ gameplay classes (AActor, APawn, ACharacter, AGameModeBase, UActorComponent), exposing properties/functions with UPROPERTY/UFUNCTION, setting up a GameMode's default classes, or adding a module dependency in *.Build.cs.
  • Use when the project has a Source/ tree with *.h/*.cpp using UCLASS, and *.Build.cs.

When not to use: designer-facing visual logic → unreal-blueprints. Player input binding details → unreal-enhanced-input. AI logic → unreal-behavior-trees. This skill owns the C++ class/reflection foundation those build on.

Core workflow

  1. Name with the right prefix. A = Actor-derived, U = UObject/component-derived, F = plain struct, E = enum, I = interface. The prefix must match the base class.
  2. Declare the class with reflection macros. UCLASS() above the class, GENERATED_BODY() as the first line in the body, and #include "ClassName.generated.h" as the last include in the header.
  3. Expose data with UPROPERTY (editor/Blueprint visibility and garbage-collection tracking) and behaviour with UFUNCTION (BlueprintCallable, etc.).
  4. Create components in the constructor with CreateDefaultSubobject<T>(TEXT("Name")) and set the RootComponent.
  5. Know the framework roles: AGameModeBase sets the rules + default classes; APawn/ ACharacter is the controllable body; APlayerController is the player's will; UActorComponent is reusable behaviour.
  6. Add module dependencies to *.Build.cs (e.g. EnhancedInput) or unresolved-symbol link errors follow.
  7. Verify by compiling (Live Coding Ctrl+Alt+F11 from the editor, or a full build from the IDE with the editor closed) and checking the class/properties appear in the editor. For automation tests, run headless with UnrealEditor-Cmd <Project>.uproject -ExecCmds="Automation RunTest MyGame;Quit" (RunTest takes a test name, a dotted prefix, or Group:<name>).

Patterns

1. Minimal Actor class (header + source)

// Pickup.h
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Pickup.generated.h"          // MUST be the last include

UCLASS()
class MYGAME_API APickup : public AActor   // MYGAME_API = your module's export macro
{
    GENERATED_BODY()
public:
    APickup();

    // EditAnywhere = tweak per-instance & on the CDO; BlueprintReadWrite = BP get/set.
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pickup")
    int32 ScoreValue = 10;

    // UPROPERTY on a UObject* pointer is what keeps it from being garbage-collected.
    UPROPERTY(VisibleAnywhere)
    TObjectPtr<UStaticMeshComponent> Mesh;   // UE5: TObjectPtr instead of raw UStaticMeshComponent*

    UFUNCTION(BlueprintCallable, Category = "Pickup")
    void Collect();

protected:
    virtual void BeginPlay() override;
};
// Pickup.cpp
#include "Pickup.h"
#include "Components/StaticMeshComponent.h"

APickup::APickup()
{
    Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
    RootComponent = Mesh;                     // the mesh is this actor's root
}

void APickup::BeginPlay() { Super::BeginPlay(); }   // always call Super
void APickup::Collect()   { Destroy(); }

2. GameMode wiring its default classes

// MyGameMode.cpp — set in the constructor so the engine spawns your classes.
AMyGameMode::AMyGameMode()
{
    DefaultPawnClass      = AMyCharacter::StaticClass();
    PlayerControllerClass = AMyPlayerController::StaticClass();
}

3. Module dependency in Build.cs

// MyGame.Build.cs
PublicDependencyModuleNames.AddRange(new string[]
{
    "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput"
});

Pitfalls

  • generated.h not last / missing — compile errors like "Cannot find generated header" or "Expected an include". It must be the final include in the header.
  • Forgetting GENERATED_BODY() — UHT (Unreal Header Tool) errors; it must be the first thing inside the class body.
  • Raw UObject* without UPROPERTY — the garbage collector doesn't see it and may destroy it out from under you. Track every UObject pointer with UPROPERTY (use TObjectPtr in UE5).
  • **Header/UPROPERTY
자주 묻는 질문

리플렉션 매크로는 무엇을 하나요?

Unreal Engine에 클래스와 속성을 알려 주어, 에디터와 Blueprint가 이를 볼 수 있게 합니다.

클래스 이름에 왜 글자 접두사가 필요한가요?

접두사는 기본 타입을 나타냅니다. 예를 들어 액터는 A를 씁니다. 접두사는 확장하는 클래스와 맞아야 합니다.

비주얼 스크립팅도 다루나요?

아니요. Blueprint 비주얼 스크립팅은 별도의 Blueprint 스킬에서 다룹니다.

상세 정보

작성자의 원본 설명

Write Unreal Engine 5 C++ gameplay code: the UCLASS/UPROPERTY/UFUNCTION reflection macros, the Gameplay Framework (GameMode, Pawn, Character, PlayerController, Actor components), and the module Build.cs. Use when writing or debugging UE C++, deriving from AActor/ACharacter/ AGameModeBase, exposing properties to the editor or Blueprints, or when the user mentions Unreal C++, UCLASS, GENERATED_BODY, GameMode, ACharacter, or .Build.cs.

repo: gamedev-skills/awesome-gamedev-agent-skills

인기도

GitHub 스타
6.6k
순위
#13854
라이선스
Apache-2.0
업데이트
2026. 10. 28.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬