gamedev-skills/unreal-cpp-gameplay
> 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.
npx skills add https://github.com/gamedev-skills/awesome-gamedev-agent-skills --skill unreal-cpp-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.4+.
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.
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.
A = Actor-derived, U = UObject/component-derived,F = plain struct, E = enum, I = interface. The prefix must match the base class.
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.
UPROPERTY (editor/Blueprint visibility *and* garbage-collectiontracking) and behaviour with UFUNCTION (BlueprintCallable, etc.).
CreateDefaultSubobject<T>(TEXT("Name")) andset the RootComponent.
AGameModeBase sets the rules + default classes; APawn/ACharacter is the controllable body; APlayerController is the player's will;
UActorComponent is reusable behaviour.
*.Build.cs (e.g. EnhancedInput) or unresolved-symbollink errors follow.
Ctrl+Alt+F11 for function bodies; full rebuild forheader/UPROPERTY changes) and checking the class/properties appear in the editor.
// 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(); }
// MyGameMode.cpp — set in the constructor so the engine spawns your classes.
AMyGameMode::AMyGameMode()
{
DefaultPawnClass = AMyCharacter::StaticClass();
PlayerControllerClass = AMyPlayerController::StaticClass();
}
// MyGame.Build.cs
PublicDependencyModuleNames.AddRange(new string[]
{
"Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput"
});
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.
GENERATED_BODY() — UHT (Unreal Header Tool) errors; it must be the firstthing inside the class body.
UObject* without UPROPERTY — the garbage collector doesn't see it and may destroyit out from under you. Track every UObject pointer with UPROPERTY (use TObjectPtr in UE5).
changes to UCLASS/UPROPERTY/headers need a full editor restart + rebuild.
UFoo (or a component AFoo) breaks UHT; match theprefix to the base type.
Build.csPublicDependencyModuleNames.
Super:: in overridden BeginPlay/Tick/etc. skips engine setup.UActorComponent creation/attachment, the UPROPERTY garbage-collection ownership rules(TObjectPtr, TArray<TObjectPtr<>>, AddToRoot), and a replication primer, read
references/components-and-gc.md.
(https://dev.epicgames.com/documentation/en-us/unreal-engine/gameplay-framework-in-unreal-engine).
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.Take gamedev-skills/unreal-cpp-gameplay from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.