unreal-cpp-gameplay
gamedev-skills/awesome-gamedev-agent-skills
Write Unreal Engine 5 C++ gameplay classes with reflection macros, Gameplay Framework, and module dependencies.
What is unreal-cpp-gameplay?
Skill for authoring UE5 C++ gameplay code using UCLASS/UPROPERTY/UFUNCTION macros, the Gameplay Framework (GameMode, Pawn, Character, PlayerController, components), and Build.cs module setup. Use when creating or debugging gameplay classes, exposing properties to the editor or Blueprints, or working with Unreal C++ architecture.
- Write Actor, Pawn, Character, and GameMode classes with correct reflection macros (UCLASS, GENERATED_BODY, UPROPERTY, UFUNCTION)
- Expose C++ properties and functions to the Unreal Editor and Blueprints with visibility and replication control
- Set up Gameplay Framework class roles: GameMode rules, PlayerController input, Pawn/Character bodies, and ActorComponents
- Create and attach components in constructors using CreateDefaultSubobject and RootComponent
- Configure module dependencies in *.Build.cs to resolve link errors and enable API access
- Verify compilation with Live Coding (function bodies) and full rebuilds (header/property changes)
How to install unreal-cpp-gameplay
npx skills add https://github.com/gamedev-skills/awesome-gamedev-agent-skills --skill unreal-cpp-gameplay- Unreal Engine 5.8 project with a Source/ directory containing *.h, *.cpp, and *.Build.cs files
- Basic C++ knowledge and familiarity with object-oriented design
- Understanding of UE's garbage collection and pointer ownership (UObject*, TObjectPtr)
How to use unreal-cpp-gameplay
- 1.Name your class with the correct prefix (A for Actor-derived, U for UObject/component, F for struct, E for enum, I for interface)
- 2.Add UCLASS() macro above the class declaration and GENERATED_BODY() as the first line in the class body
- 3.Include the generated header file as the last #include in your header file (e.g., #include "ClassName.generated.h")
- 4.Declare properties with UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "...") to expose them to the editor and Blueprints
- 5.Declare functions with UFUNCTION(BlueprintCallable, Category = "...") to expose them as callable from Blueprints
- 6.Create components in the constructor using CreateDefaultSubobject<ComponentType>(TEXT("Name")) and assign RootComponent
- 7.Add required module dependencies to your *.Build.cs PublicDependencyModuleNames (e.g., "EnhancedInput", "GameplayTasks")
- 8.Compile the project; use Live Coding (Ctrl+Alt+F11) for function body changes, full rebuild for header/UPROPERTY changes
Use cases
- Creating a custom Character class with exposed properties for a multiplayer game
- Setting up a GameMode that spawns specific Pawn and PlayerController classes
- Building reusable ActorComponent behavior (e.g., health, inventory) with UPROPERTY tracking
- Exposing gameplay variables to designers via the Editor Details panel without touching Blueprints
- Debugging unresolved external symbol errors by adding missing module dependencies to Build.cs
- C++ gameplay programmers building core game systems
- Gameplay engineers setting up Gameplay Framework architecture
- Developers migrating Blueprint logic to C++ for performance or team workflow
- Technical leads establishing module dependencies and class hierarchies
unreal-cpp-gameplay FAQ
Use UPROPERTY for any UObject pointer (to prevent garbage collection), any property you want visible in the Editor or callable from Blueprints, and any data that needs replication in multiplayer. Plain members are fine for local, non-UObject data that doesn't need editor exposure.
GENERATED_BODY() is a macro that injects reflection metadata and constructor code generated by Unreal Header Tool (UHT). It must be the first line inside your class body (after the opening brace). Forgetting it causes UHT errors.
The header's module is not listed in your *.Build.cs PublicDependencyModuleNames. Add the module name (e.g., "EnhancedInput") to the array and rebuild the project.
No. Live Coding only recompiles function bodies. Changes to UCLASS, UPROPERTY, UFUNCTION, or any header structure require a full editor restart and project rebuild.
EditAnywhere allows editing both the Class Default Object (CDO) and per-instance values; EditDefaultsOnly only the CDO; VisibleAnywhere shows the property in the editor but prevents editing. Pair with BlueprintReadWrite/BlueprintReadOnly to control Blueprint access.
Full instructions (SKILL.md)
Source of truth, from gamedev-skills/awesome-gamedev-agent-skills.
name: unreal-cpp-gameplay description: > 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.
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 withUPROPERTY/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/*.cppusingUCLASS, 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
- 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. - 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. - Expose data with
UPROPERTY(editor/Blueprint visibility and garbage-collection tracking) and behaviour withUFUNCTION(BlueprintCallable, etc.). - Create components in the constructor with
CreateDefaultSubobject<T>(TEXT("Name"))and set theRootComponent. - Know the framework roles:
AGameModeBasesets the rules + default classes;APawn/ACharacteris the controllable body;APlayerControlleris the player's will;UActorComponentis reusable behaviour. - Add module dependencies to
*.Build.cs(e.g.EnhancedInput) or unresolved-symbol link errors follow. - Verify by compiling (Live Coding
Ctrl+Alt+F11for function bodies; full rebuild for header/UPROPERTY changes) and checking the class/properties appear in the editor.
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.hnot 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*withoutUPROPERTY— the garbage collector doesn't see it and may destroy it out from under you. Track every UObject pointer withUPROPERTY(useTObjectPtrin UE5). - Header/UPROPERTY edits with Live Coding — Live Coding handles function bodies, but
changes to
UCLASS/UPROPERTY/headers need a full editor restart + rebuild. - Wrong class prefix — naming an Actor
UFoo(or a componentAFoo) breaks UHT; match the prefix to the base type. - Unresolved external symbol at link — the module providing the API isn't in
Build.csPublicDependencyModuleNames. - Not calling
Super::in overriddenBeginPlay/Tick/etc. skips engine setup.
References
- For
UActorComponentcreation/attachment, theUPROPERTYgarbage-collection ownership rules (TObjectPtr,TArray<TObjectPtr<>>,AddToRoot), and a replication primer, readreferences/components-and-gc.md. - Primary docs: "Unreal Engine CPP Quick Start" and "Gameplay Framework"
(
https://dev.epicgames.com/documentation/en-us/unreal-engine/gameplay-framework-in-unreal-engine).
Related skills
unreal-blueprints— exposing C++ to designers; BP/C++ interop.unreal-enhanced-input— binding input in a C++ Pawn/Character.unreal-behavior-trees— C++ AI tasks driven from a behaviour tree.
Related skills
More from gamedev-skills/awesome-gamedev-agent-skills and the wider catalog.

unreal-enhanced-input
Set up player input in Unreal Engine 5 with Enhanced Input system: Input Actions, Mapping Contexts, modifiers, and triggers.

unreal-niagara
Create and control real-time particle effects in Unreal Engine 5 with Niagara systems, emitters, and modules.

unreal-packaging
Package and ship UE5 projects with editor menus or command-line BuildCookRun automation.

visual-novel
Build branching visual novels with script engine, character display, choices, and player conveniences like save/load and skip.

gemini-watermark-remover
Remove visible Gemini watermarks from local images via CLI.

gpt-image-2
Full OpenAI-compatible GPT Image 2 coverage for text-to-image, edits, and streaming responses.