Unreal C++
Pocket Guide

Unreal C++ Guide Overview
Unreal Engine 5 features high-level gameplay programming through Blueprints and low-level gameplay programming through Unreal C++.
From a historical perspective, since the release of Unreal Engine 4 in 2014, Epic Games has replaced UnrealScript, the gameplay scripting language used in previous Unreal Engine generations, with Unreal C++, while Blueprints replaced the Kismet visual scripting tool in Unreal Engine 3 & UDK.
For the next iteration, Unreal Engine 6, Blueprints and the Actor-based architecture will continue to ship alongside the new Verse programming language and Scene Graph architecture. Then, according to Epic Games’ roadmap, Blueprints and Actors will be deprecated.
Throughout my Unreal C++ guide, I use the term “Unreal C++” to refer to C++ used within Unreal Engine, as opposed to what I call “Standard C++”, which refers to C++ outside of any game engine or framework.
// Note: Apparently, Blueprints might get deprecated sooner in Unreal Engine 6. I will update this guide once I get more information.
C++ Prerequisites
In my opinion, learning at least some parts of the Standard C++ is essential before diving into Unreal C++, as many things, including Blueprints, integrate concepts built on top of it. You need to be aware of concepts such as:
- Headers & Source files
- Variables, Functions, Classes, Structs & Objects
- Object-Oriented Concepts
- Inheritance, Encapsulation, Polymorphism, Abstraction
- Constructors, Destructors
- Memory management: Pointers, References, Smart Pointers
- Metaprogramming: Macros, Preprocessor Directives, Templates
- Enums
- RAII
- Data Structures: Standard Containers (
std::vector, std::map) and their Unreal equivalents (TArray, TMap)
Moreover, I suggest to continuously do some Standard C++ exercises on a simple console in Visual Studio 2026. You never stop learning C++ as new features are shipped roughly every three years.
Getting Started
Installation
- Install Unreal Engine 5 binary version through the Epic Games Store launcher.
- Visual Studio 2022 or 2026 can be used (for 2026, I do believe that you still have to install 2022)
- Use the SLN and not SLNX file.
- You can use Rider if you want (I don’t use it).
- Epic Coding Standards
Unreal C++ Introduction
- Avoid using the C++ Standard Library (STL or std::). Unreal C++ usually provides engine-specific alternatives compatible for every supported platforms (consoles, mobile, etc.).
- Unreal Engine 5 still relies on the traditional header
(.h) and source (.cpp) file structure, and doesn’t use modules introduced in Standard C++ 20.
- A
Header File is the declaration file that contains class definition, function signatures, etc.
In Unreal Engine, headers contains UHT special macros like UPROPERTY() and UFUNCTION()
- A source file contains the implementation of everything.
- I do not know if Unreal Engine 6 will use C++ modules, either for Unreal codebase itself or if it will allow modules for the C++ part of a game project.
Debug Text & Shapes
- Two ways to display debug text:
UE_LOG and GEngine
UE_LOG prints text to the Output Log window in UnrealEd (the Unreal Editor).
- It has arguments such as the Verbosity (Display for white text, Warning for yellow, Error for red, etc.)
UE_LOG also requires format specifiers (based on C printf)
%d for int32
%f for float
%s for bool and text like FString, FVector.ToString(), and FRotator.ToString()
GEngine is for on-scren debug message.
- There are visual debugging shapes, such as
DrawDebugLine or DrawDebugSphere.
// Blueprint only exposes int32 for signed integers and uint8 for unsigned integers
int32 Score = 10; // Fixed-size ints are preferred
float Health = 250.0f;
bool bIsAlive = true;
FString Name = TEXT("Charlotte"); // Use a pointer *Name to converts FString to const TCHAR*
UE_LOG(LogTemp, Warning, TEXT("Name: %s"), *Name)
FVector Location = GetActorLocation();
FRotator Rotation = GetActorRotation();
FTransform Transform; // convert .ToString() if necessary
if (Health <= 0) { bIsAlive = false; }
else {bIsAlive = true; }
bIsAlive = (Health > 0) ? true : false;
bIsAlive = (Health >0)
for (int32 i = 0; i < 10; i++)
{ UE_LOG(LogTemp, Warning, TEXT("Index: %d"), i); }
Blueprints & Unreal C++
- Unreal C++ and Blueprints are designed to work together:
C++ as the foundation for low-level gameplay systems and base classes (Actors, Characters, Controllers…)
Blueprints for high-level stuff
- Unreal C++ is more verbose but more performant than
Unity C#. Unity C# is equivalent to Blueprints, not Unreal C++.
- Beginners should use Unreal C++ progressively, while still prototyping most stuff in Blueprints
Ideally, every Actor that is instanced in the World, whether it’s regular Actors (Actor, Pawn, Character, etc.) or Framework (GameMode, GameInstance…),
should have a derived Blueprint class to prototype new features quickly.
Introducing C++ from a Blueprint prototype is mostly about removing Blueprints code while creating a new C++ class and changing the Bluperints parent.
(from the base Actor class to your own CPP class for instance).
Preventing Blueprints Lock-in
- It’s important to create C++ classes, and even use empty C++ functions rather than using critical system in Blueprints. Otherwise, it might be impossible to move from Blueprint to Unreal C++ without rewriting the entire system, and potentially change dozens of actors.
Project Recovery / Regenerating
Knowing how to recover a project is extremely important.
- You can regenerate Visual Studio project file with the .uproject file;
- Some problems require to remove some files from the project’s folder.
- You can also zip your project (File > Zip project) to keep things and regenerate your project in Unreal C++
Cannot import FBX Files
- When importing some Skeletal Meshes, it might break some things in C++. No problem to continue running the project, but I’ll have to zip it and regenerate it.
File created but never used
For a class created but never used anywhere:
- Close Unreal Engine and Visual Studio
- Delete
.h and .cpp files
- Delete Binaries and Intermediate folders from the project
- Generate 📁 project files from the Uproject file
- Reopen
Impossible to regenerate the project
Whatever the reason might be, if you need to recreate a new project:
- Create a new project with the same Unreal Engine version (like 5.8)
- Copy 3 folders into the new project:
- 📁 Config, Content, and Source
- With the new project, recreate C++ modules:
- Add a single random class from UnrealEd to let Unreal regenerating a new .sln
- Re-add source files manually into the new 📁 Source folder
- Regenerate the .sln from the .Uproject
- Make sure Unreal register new classes in Build.cs
Unreal C++ Workflow
- Low-Level in C++: Create the core gameplay systems (heavy logic, math) in Unreal C++
- Expose to Editor: Expose variables and functions to UnrealEd using Unreal Reflection macros (
UPROPERTY, UFUNCTION).
- Extend in Blueprints: Create Blueprint Child Classes derived from C++ parent classes
- Change visuals in Blueprints: modify Static Meshes & Skeletal Meshes, values, sounds, Niagara particles, animations, or simple gameplay logic inside Blueprints
Actors
Light Switcher Actor
A Light Switcher actor in Unreal Engine that turns a light on/off when the player walks into a box. We’ll write it in C++ and expose it to Blueprints.
- Create a new LightSwitcher Blueprint to learn how to reparent any Blueprint
- Create a new LightSwitch C++ class without Public/Private but inside a specific subfolder
➡️ Check in Training folder Light/LightSwitcher.h
The UPROPERTY() macro make the variable visible to the engine.
LightSwitcher Source
➡️ Check in Training folder Light/LightSwitcher.cpp
Material Switcher Actor
Double Door Actor
Unreal Framework
- Subsystems
- GameInstance Subsystems
- World Subsystems
- Engine Subsystems
UHT
Unreal Reflection System Overview
🕵️ Unreal’s reflection system lets the engine inspect and interact with C++ code at runtime,
enabling Blueprints, serialization, garbage collection, and Editor UI.
The Unreal Header Tool (UHT) parses .h files and reads special macros such as UCLASS() or UPROPERTY() to generate
reflection data. All reflected definitions must be declared in the .h header file.
Macros like UCLASS(), UPROPERTY(), and UFUNCTION() belong exclusively in .h header files (declaration).
the .cpp source file contains only the implementation, with no reflection macros needed.
Macros
UCLASS() marks a class as part of the reflection system. The class must also inherit from UObject (directly or indirectly).
UPROPERTY() exposes a variable to the engine and controls Editor visibility, Blueprint access, replication, and garbage collection.
UFUNCTION() exposes a function to the engine and is required for Blueprint calls, RPC (networking), and delegate/event bindings.
Overlap callbacks, for example, must carry this macro.
// Exposed to Editor (read-only), managed by garbage collector
UPROPERTY(VisibleAnywhere)
class UBoxComponent* TriggerVolume;
// UFUNCTION() required for binding to overlap delegate
UFUNCTION()
void OnOverlapBegin(
UPrimitiveComponent* OverlappedComp,
AActor* OtherActor,
UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex,
bool bFromSweep,
const FHitResult& SweepResult
);
Common Specifiers to Master
BlueprintReadOnly or BlueprintReadWrite: Controls accessibility within Blueprint graphs.
EditAnywhere or VisibleAnywhere: Dictates whether a property can be edited or just viewed within the Details Panel (Archetype vs. Instance).
Category: Categorizes properties logically within the Unreal Editor UI.
Naming Conventions
The Unreal Header Tool (UHT) enforces correct prefixes on reflected types, and using the wrong one triggers compiler warnings or errors.
No need to add any prefix when creating a C++ class through UnrealEd.
-
A for Actor, any object placeable in the world (AStreetLight)
-
U for UObject, components and assets that are not Actors (UBoxComponent)
-
F for structs and plain C++ classes, not garbage collected (FHitResult)
-
E for enums (EStreetLightState)
-
I for interfaces (IInteractable)
-
T for templates (TArray, TMap)
-
Each project usually has a common prefix. For instance, it could be AUTCharacter for Unreal Tournament or AFortPlayerPawn for Fortnite.
Memory Management & Smart Pointers
Unreal Engine uses an automated Garbage Collection (GC) system for all UObject derived classes.
However, it requires explicit developer adherence to reflection rules to prevent bugs (memory leaks, segmentation faults).
Garbage Collector (GC)
- Any
UObject* or AActor* pointer must be marked with a UPROPERTY() macro if it is stored as a class member variable.
- Without
UPROPERTY(), the Garbage Collector cannot see the pointer reference and will treat the object as unreferenced and delete it out from under you, leaving a dangling, corrupt pointer.
Non-UObject Memory (Smart Pointers)
Standard C++ smart pointers (std::shared_ptr, std::unique_ptr) should never be used with UObject classes.
For raw C++ classes (F structures) or non-engine data, Unreal provides its own performance-optimized memory utilities:
TSharedPtr: Reference-counted smart pointer for non-UObject data types.
TUniquePtr: Sole-ownership smart pointer that deletes the allocated object when it goes out of scope.
TWeakObjectPtr<T>: Used safely with UObjects. It provides a weak reference that does not prevent Garbage Collection, but allows you to safely check if an object is still valid (.IsValid()) before invoking its methods.
References
Fundamental Courses
- Unreal Engine 5 C++ Multiplayer Shooter. Stephen Ulibarri, June 2024.
- Unreal Engine 4 C++ The Ultimate Shooter Course. Stephen Ulibarri, January 2023.
- Unreal Engine 5 C++ Developer: Learn C++ & Make Video Games. Ben Tristem, January 2024.
- Unreal Engine 5 C++ The Ultimate Game Developer Course. Stephen Ulibarri, May 2024.
Articles
YouTube Videos
★ Tests
Quiz
AI Prompt (Gemini or Copilot) for beginner quiz:
- Create a beginner-level quiz about Unreal Engine C++ with 10 different questions.
- Focus on core fundamentals for Unreal C++.