---
description: Unreal Engine 5 C++ gameplay conventions
globs: ["Source/**/*.{h,cpp}","**/*.Build.cs"]
alwaysApply: false
---

# Unreal Engine 5 gameplay (C++)

- Reflection macros on everything the engine or Blueprints touch: `UCLASS()`, `USTRUCT(BlueprintType)`, `UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Combat")`, `UFUNCTION(BlueprintCallable)`. Include `"X.generated.h"` last.
- UObject pointers in headers are `TObjectPtr<T>` members marked `UPROPERTY()` so GC tracks them; use `TWeakObjectPtr` for non-owning references that may die. Never raw `new`/`delete` UObjects; create with `CreateDefaultSubobject` (constructor) or `NewObject`/`SpawnActor`.
- Prefer composition with `UActorComponent`s over deep actor inheritance.
- Input with Enhanced Input: `UInputAction`/`UInputMappingContext` assets, bound in `SetupPlayerInputComponent` via `UEnhancedInputComponent::BindAction`.
- Expose tuning values as `EditDefaultsOnly` properties or Data Assets; designers tune in Blueprint subclasses, C++ owns logic.
- Use `BlueprintImplementableEvent`/`BlueprintNativeEvent` for designer hooks.
- Tick: disable (`PrimaryActorTick.bCanEverTick = false`) unless needed; use timers (`GetWorldTimerManager().SetTimer`) or events.
- Use `UE_LOG(LogMyGame, Warning, TEXT("..."))` with a declared log category; `check`/`ensure` for invariants.
- Gameplay Ability System for abilities/attributes if the project uses it; don't build a parallel system.
- Keep includes minimal in headers (forward declare), include what you use in `.cpp`.

## Done when
The editor target builds (`Build.bat <Project>Editor Win64 Development` or via IDE) with no new warnings, and Live Coding/hot reload is not relied on for header changes (restart the editor).
