How Unreal Engine Works: Not an API, but Engineering Thinking
This is not an article about "how to make a game in Unreal." This is an article about why the engine is built the way it is — and if you truly understand the line of reasoning below, you will be able to predict the architecture of any engine system you haven't studied yet, instead of having to memorize it from scratch every time.
01What is it?
Unreal Engine is not one thing, but a layered cake of several different engineering solutions, each of which addresses its own distinct problem: Engine (the engine itself as a program and as ready-made infrastructure), Framework (the control model into which your code is embedded), UObject (the object model shared by C++ and the editor), Reflection (the engine's ability to "see" the structure of your classes at runtime), and Garbage Collector (automatic management of object lifetime). This article shows that all five are not a random set of features, but a single chain of cause and effect: each subsequent solution exists because the previous one creates a problem that needs to be solved. By walking through this chain once, consciously, you gain not five facts to memorize, but one way of thinking applicable to any other engine system.
02Why does it exist?
The problem: 1997, a studio is making a shooter
Imagine a team that sits down in 1997 to make a 3D shooter. Just to get the game to launch and react to anything at all, they have to write from scratch: rendering of 3D graphics on top of a specific manufacturer's video card, a loader for 3D models and textures from files on disk, keyboard and mouse input handling, collision and gravity physics, a sound engine, network code for multiplayer that accounts for network latency, a level editor so designers can place objects with a mouse rather than lines of code, and a save/load system for game state. None of these eight things has anything to do with what makes this particular game THIS game rather than some other — it is pure infrastructure, without which the game physically cannot run, but which is not itself gameplay.
The team spends the overwhelming majority of its time reinventing the renderer, the asset loader, and the editor — that is, on things that do not distinguish one game from another — and only a small remainder on what players actually see and feel: weapon balance, level design, animation timing, the feel of shooting.
The cause: infrastructure does not transfer between projects by itself
The problem is not that infrastructure is hard to write (although it is) — the problem is that the knowledge of how to write it does not transfer structurally between projects. If a studio has no shared engine, the next game starts almost from scratch again: even if the same programmer who wrote the renderer for the first game writes the renderer for the second, they write it anew, because there is no shared, reusable piece of code — there is only the experience in one person's head, which is hard to pass on to the team and impossible to quickly adapt to a new task.
The first attempted solution — buy separate, independent libraries
The natural next step is not to write everything from scratch, but to take ready-made third-party solutions: a third-party renderer, a third-party physics engine like early PhysX, a third-party sound SDK — and write your own code that calls each library separately.
Each such library is just a set of functions you call. The library knows nothing about your game objects: it does not know what an "Actor" is, that the player just entered the level or picked up an item. The glue between several independent libraries — a shared game object model, an editor that can work with all systems at once, a state save system, network synchronization of all of it — still has to be written by you, and this glue turns out to be the hardest part of the work, not the easiest, because now you have to reconcile foreign APIs that were not designed for each other.
03What problem does it solve?
Epic's answer to this problem is not a "more convenient library," but a change in the very model of the relationship between your code and the infrastructure. Instead of you calling a set of independent libraries and being the assembly point of the entire project yourself, the engine itself becomes the assembly point: it owns the program's main loop, it owns the shared object model, it owns the editor, it owns the load/save system — and your code becomes a set of extension classes that the engine uses at predictable, predefined points. This solves the original problem not by "writing infrastructure faster," but by making the overwhelming majority of the infrastructure unnecessary to rewrite at all — Epic wrote it once, and now it is reused in every project on the engine, and the team actually spends its time on what distinguishes its game from others.
04How is it built?
What an Engine is — and why that alone is not enough to answer "what is Unreal"
The word "Engine" by itself describes only part of the picture: a set of technical subsystems that together turn data (models, textures, sounds, code) into a working interactive simulation — rendering, physics, sound, networking, the asset system. That is already an enormous engineering effort in itself, but if Unreal were "only" a set of such subsystems exposed through an API, it would remain exactly that set of independent libraries from section 2, just written by one company instead of assembled from different sources. What turns a set of technical subsystems into a cohesive system that a development team can work with productively is not about rendering or physics — it is about who controls whom. And that is precisely the question answered by the next concept — Framework.
What a Framework is — and why Unreal Engine is a framework, not a library
The distinction between a library and a framework lies not in the size of the code, the number of functions provided, or the complexity of the API — one of the most telling criteria for this distinction, though not the only one, as will be clarified below, is who owns control over the program's execution architecture and who, ultimately, decides when user code is called.
When a developer uses an ordinary library (for example, a utility for reading PNG files), architectural control remains entirely with them: they have their own main() function, they organize the application's main loop themselves, and at an arbitrary point in time they initiate a call to the necessary library function — "load a file," "process an array of data," "return a result." The library, in turn, acts solely as a provider of ready-made functionality, passively waiting for the client code to call it; it has neither knowledge of the calling application's structure nor the authority to interfere with its life cycle.
With a framework, the picture is diametrically opposite: it provides the developer not a scattered set of utilities, but a holistic application skeleton, including rules for organizing the codebase, a predefined sequence of object initialization and destruction, a system for inter-component communication, as well as pre-specified extension points into which user code can be integrated. Unreal Engine belongs precisely to this class of systems. When a programmer creates a derived class, say, AActor, they do not construct their own game loop — the program's entry point is firmly held by the engine's executable module, while their code is embedded into the existing life cycle by implementing functions with fixed signatures — BeginPlay, Tick, EndPlay; the engine itself decides, in a strictly defined order of its own, when exactly each of these functions should be called. Thus, the method written by the developer becomes not an entry point, but an extension point, activated by the external execution environment.
This architectural approach is called Inversion of Control (IoC) and consists in the main flow of program execution passing from the user code's control to the framework's control, which dictates both the sequence and the timing parameters for invoking the plugged-in modules.
An ordinary program with a library (control is yours):
int main() {
Init();
while (running) {
ProcessInput();
Update();
Render();
}
}
→ The main loop is defined by the developer.
→ The order of subsystem execution is set by the developer.
→ The library never initiates calls;
it is invoked at the initiative of the client code.
A class inside Unreal Engine (control belongs to the framework):
void ASA_Character::BeginPlay()
{
/* your code */
}
void ASA_Character::Tick(float DeltaTime)
{
/* your code */
}
→ main() is held by the engine.
→ Unreal manages object creation and their lifetime.
→ The engine determines when to activate BeginPlay,
how often to call Tick,
and at what point to finalize the object.
→ After the user code finishes, the engine continues
its loop, sequentially updating physics, networking,
rendering, and related subsystems.
→ Therefore, the user function is
an extension point, not an entry point.
int main() { ... } is a special function where execution begins in an ordinary C++ program: when the program is launched, it is the first thing called, not anything else. while (running) { ... } is a loop: as long as the condition in the parentheses (here — the variable running) is true, the code inside the curly braces runs again and again, line by line, not just once.
void ASA_Character::BeginPlay() — the double colon here is used differently than when calling an existing function: it is a way to write the implementation of a method outside the class body — to say "here is the code for the BeginPlay function, which was declared inside the ASA_Character class," without rewriting the entire class declaration. float DeltaTime in the parentheses of Tick is a parameter: a value passed to the function by the caller (in this case — the engine itself, passing the duration of the elapsed frame in seconds), available inside the function as an ordinary variable.
Inversion of control is not an architectural luxury or a tribute to aesthetics — it is a forced and the only viable solution that allows one and the same executable engine core to serve thousands of diverse projects, each operating with its own unique game logic.
If each individual project took responsibility for controlling the startup order of subsystems, developers would have to manually determine when to create the game world, initialize the physics engine, rendering, network connections, and other infrastructure components; and any mistake in building this sequence — for example, trying to access a level that has not loaded yet or an uninitialized object — would inevitably lead to instability and, in the worst case, a crash.
When the engine fully owns the application's life cycle, it guarantees a uniform and correct initialization order for all projects without exception; the developer, in turn, works inside an already prepared, proven architecture, and their task narrows down to filling in specific, pre-defined extension points, without touching critical system mechanisms.
Although inversion of control is one of the most characteristic features of modern frameworks, especially those that take over application life-cycle management, it should be understood that IoC is not the only possible and mandatory criterion for classifying a software system as a framework.
There is a significant number of frameworks that provide the developer with cross-cutting system capabilities — such as dynamic memory management, reflection, serialization, an event model, a build system, or strict architectural patterns — but still leave the main() function under the client code's full control, without imposing their own execution model.
Thus, a more correct understanding of a framework is not as "a system that necessarily seizes control," but as an architectural foundation that provides a common infrastructure layer on top of ordinary application code, structuring it and making it easier to solve typical tasks.
In the case of Unreal Engine, inversion of control is one of the central mechanisms of the architecture: the engine firmly holds the main loop, fully controls object lifetime, and calls user implementations through predefined extension points, which is what allows Unreal to be classified not as a vast collection of functions, but precisely as a full-fledged framework dictating its own model of application execution.
Why ordinary C++ was chosen as the foundation — and why it alone is not enough
Constraint #1: the frame budget
A real-time game must recalculate physics, AI, animation, rendering, and game logic within a single frame. At 60 frames per second, that is 16.6 milliseconds total for everything listed. Languages with automatic memory management via a garbage collector that can, at any unpredictable moment, "pause" and scan the entire heap (the classic model of early Java, as well as most managed runtime implementations) — introduce unpredictable pauses exactly when the collector sees fit. This is unacceptable when the frame budget is already at its limit: one such pause in the middle of a battle scene is a noticeable frame-rate hitch for the player (the so-called micro-stutter). C++ gives direct control over object lifetime and memory layout, which is what is needed to keep that budget predictable, frame after frame.
Constraint #2: thousands of mutually referencing objects, controlled not only by the programmer
Manual memory management in C++ (your own new/delete for every game object) in a project where thousands of actors hold pointers to each other — an actor holds a pointer to its target, a component holds a pointer to its owner, AI holds a pointer to the last enemy it spotted — is a direct source of constant use-after-free bugs if managed by hand. The problem is compounded by the fact that in Unreal, objects are created and destroyed not only by your code, but also by the editor, by the level-loading system, and by network code when a player disconnects — meaning you, as the author of a specific class, physically cannot track all the places where a pointer to your object might come from.
The conclusion from both constraints simultaneously: you need a language with manual control over execution timing (which means C++, not a managed language with an unpredictable GC), but at the same time you need protection from use-after-free for objects referenced by many different, unrelated engine systems (which means some form of automatic lifetime management, but only for this specific category of objects, not for all of the program's memory). This constraint is the direct cause of everything described further in this article: Unreal does not choose between "fast but dangerous C++" and "safe but pause-prone managed language" — it builds a third option: performant C++ as the core, and a thin, predictable garbage-collection layer only for one specific category of objects (more on that in the Garbage Collector section).
Reflection and the Garbage Collector in Unreal are not inventions of the modern version of the engine. Early versions of the engine (Unreal, 1998, and the subsequent Unreal Engine 2 and 3) used a separate language for game logic — UnrealScript: interpreted, with built-in garbage collection and reflection from the very beginning, while the low-level core of the engine (rendering, physics) was written in C++. Unreal Engine 4 (2014) removed UnrealScript as a separate language and transferred its role to "real" C++, augmented by code generation through the Unreal Header Tool — but preserved the same idea: game objects must be manageable, reflectable, and convenient to write on the fly, even if the engine core remains low-level and free of these overheads. In other words, Reflection and GC in modern Unreal C++ are not a new idea added on top of "ordinary" C++, but a port of nearly twenty years of proven architecture to a new, more performant implementation language.
Why UObject appeared
The constraint from the previous section formulates the task: you need a separate category of objects for which the engine takes on automatic lifetime management, editor integration, and serialization — while the bulk of the engine's code (math, containers, low-level systems) remains ordinary, "bare" C++ without these overheads. Epic's answer is to introduce an explicit boundary: any class that needs these capabilities inherits from the common base class UObject, and that very fact of inheritance is a signal to the rest of the engine's infrastructure (the garbage collector, the editor, the serialization system) that this particular object must be handled by special rules. Ordinary C++ classes that do not meet these requirements (for example, a simple mathematical structure like a vector) stay outside this system — and do not pay for capabilities they do not need.
UObject is not "the base class for everything in Unreal." It is a deliberately drawn boundary: on one side — objects managed by the engine's infrastructure (life cycle, GC, editor, networking, serialization), on the other — ordinary C++ without any of that. The decision whether to inherit from UObject is an architectural decision with a real cost (see the section on memory and performance impact below), not an automatic default choice for every new class.
A detailed breakdown of UObject's internals — the constructor, Class Default Object, the difference between UObject and AActor — is in a separate article (see the "what to study next" block at the end), because the topic is large enough to deserve its own full treatment by the same standard. Here it is important to establish only one thing: UObject is the answer to a specific engineering constraint, not an arbitrary architectural decision.
Why Reflection appeared
Introducing UObject as a boundary solves the question of "which objects are special," but it does not solve the next, no less important question: how does the engine infrastructure — the garbage collector, the editor, the save system — find out which exact fields your particular UObject-derived class has, if that infrastructure itself was written once, long before you write your class?
Ordinary C++ erases almost all information about type structure after compilation (this phenomenon is called type erasure) — in the compiled binary there is no built-in, runtime-accessible list saying "the class ASwordActor has a field float BaseDamage at such-and-such an offset in memory." The compiler knows this precisely at build time, but does not leave that knowledge available to the running program. For writing game code, this is usually enough — you already know the names of your fields at the time you write the code. But for writing a universal editor that must be able to show a Details panel for absolutely any class that any programmer on this engine will ever write, including classes that will be written years after the editor version's release — this limitation is fatal. The editor physically cannot be written to "know" in advance about every future class of every future project.
The solution — code generation on top of your class, before the main compilation
Epic solves this problem not by changing the C++ language (that would be impossible — the C++ compiler is not under Epic's control), but by an additional build step before the main compilation: Unreal Header Tool (UHT) — a separate program that scans your header .h files, finds special macros (UCLASS, UPROPERTY, UFUNCTION), and generates additional C++ code — a .generated.h file — that registers your class's structure in the engine's runtime system: the list of fields, their types, their offsets in memory, the list of functions. This generated code is Reflection in Unreal — runtime-accessible information about class structure, synthesized automatically from your source code before the regular C++ compiler ever even sees the file.
Ordinary C++ project build:
your .cpp/.h files → compiler (clang/MSVC) → binary
(information about class structure
is erased after compilation)
Unreal Engine project build:
your .h file with UCLASS()/UPROPERTY()
│
▼
Unreal Header Tool reads the .h, SEES the macros,
generates MyClass.generated.h — code that
registers the class structure in UClass/FProperty
│
▼
your .cpp/.h + .generated.h → compiler (clang/MSVC) → binary
(now the binary contains both your logic
AND a runtime description of the class structure —
the editor and GC can read it at runtime)
The macros (UCLASS(), UPROPERTY(), GENERATED_BODY()) are not a stylistic whim, but the only way available to Epic to mark the necessary classes and fields right in an ordinary, valid C++ file so that: (a) a separate program (UHT) can find these marks by simple textual parsing of the header before full compilation, while at the same time (b) the file itself remains compilable by an ordinary C++ compiler, which simply expands these macros into nothing or into utility code at the preprocessing stage. The alternative — a separate interface description file (the so-called IDL, Interface Definition Language, used, for example, in COM or CORBA) — would force the developer to manually maintain two synchronized sources of truth (the C++ class and its IDL description) instead of one. Macros allow keeping the entire description in one place — right above the field or class it refers to — and that is precisely why Epic chose this path rather than a separate description format.
In UObject/ObjectMacros.h, the macros themselves are deceptively simple: UPROPERTY(...) and UFUNCTION(...) literally expand to nothing — #define UPROPERTY(...) with not a single character on the right side, and the engine developers' comment right above them says exactly that: "These macros wrap metadata parsed by the Unreal Header Tool, and are otherwise ignored when code containing them is compiled by the C++ compiler". UCLASS() and GENERATED_BODY() are trickier — they expand not to nothing, but to a token glued together from the file name and line number, which during compilation substitutes in its place the code generated by UHT in .generated.h. And a detail that usually surprises those who studied the engine from older materials: UHT itself in current engine versions is no longer a C++ program, as it was in UE4, but a C# toolchain (in the source tree it lives as Engine/Source/Programs/Shared/EpicGames.UHT, next to the Unreal Build Tool). The model described above — "first UHT reads the macros, then the ordinary compiler builds the result" — is unaffected; only the implementation language of the tool itself changes, not its role in the pipeline.
Why the Garbage Collector is needed
Reflection solves the problem of "the engine knows your class's structure at runtime" — but that very same knowledge turns out to be exactly the missing piece needed to solve the safe memory management problem formulated in section 6: if the Reflection system already knows how to find all pointer fields to other UObjects inside your class (via UPROPERTY, which marks exactly such fields), then the engine can build a complete reference graph between all live UObject instances in the game — who references whom — and periodically walk this graph, starting from known "live" root objects (the world, GameInstance, and similar), marking everything reachable as alive, and deleting everything unreachable. This is Unreal's Garbage Collector — a mechanism that became possible precisely thanks to Reflection, not one that appeared independently of it.
A simplified model of a GC pass (mark-and-sweep):
Root objects (GameInstance, UWorld, objects with AddToRoot)
│
▼ traversal via UPROPERTY references (known thanks to Reflection)
│
┌────┴────┐
▼ ▼
Actor A Actor B ──▶ Component X ──▶ InventoryItem Y
│
▼
(if nothing else references this, the object is NOT marked as alive)
After the traversal: everything that was NOT marked as reachable
is considered garbage and freed on the next GC pass.
The GC can only traverse references whose existence it knows about — and it only knows about fields registered by Reflection, that is, fields marked with UPROPERTY. An ordinary, "raw" C++ pointer to a UObject (AActor* CachedTarget; without UPROPERTY) is invisible to the GC: it is not part of the traversal graph, and the object it points to can be deleted by the collector even if that "raw" pointer to it still exists somewhere in memory. You will get a pointer that looks valid (not nullptr), but points to already freed memory — classic use-after-free, only masked as a normally working engine, because at first glance the code compiles and seems to work. This is the direct reason why in real projects any pointer field to a UObject should almost always be marked with UPROPERTY — not for editor visibility, but for physical memory safety.
Starting with UE5, when UHT sees UPROPERTY() AActor* Target;, the generated code declares this field not as a bare AActor*, but as TObjectPtr<AActor> (UObject/ObjectPtr.h) — a wrapper around a "handle" to the object (UObject/ObjectHandle.h). Epic's comment above TObjectPtr explains exactly why: "is meant to function as a drop-in replacement for raw pointer member properties... supports access tracking and optional lazy load behavior in editor builds... When resolved, its participation in garbage collection is identical to a raw pointer". In everyday code (Target->DoSomething()) nothing changes — the same size, the same direct access by address, the same participation in GC traversal. But every access to the field becomes a point the engine can track, rather than an opaque address in memory — this is used by the GC barrier and (in editor builds) lazy loading of an object that is not loaded yet. The section's idea does not change: without UPROPERTY, a reference is still invisible to the GC — it's just that a visible reference has a bit more mechanics under the hood than "just a pointer."
It is important that this GC does not work like in managed languages such as C# or Java — it does not scan unpredictably at any moment, but runs on a controlled schedule (usually once every several seconds; the exact interval is configurable), and the traversal itself is designed to fit within the frame budget rather than stop the entire game. This is a direct consequence of constraint #1 from section 6 — predictability matters more than instant reaction to memory deallocation.
How it all connects — a single chain of causes
Now that each element has been broken down separately, it is worth explicitly tracing the entire chain as a whole — because its wholeness, not the individual facts, is the main lesson of this article.
- Problem: rewriting all of a game's infrastructure from scratch for every project is economically unviable.
- Solution 1 — Framework: the engine takes control of the main loop (inversion of control); your code becomes a set of extension points.
- Constraint: a real-time engine needs a predictable, fast language without managed-runtime pauses — C++ is chosen.
- New problem from this choice: manual memory management in C++ for thousands of mutually referencing game objects, controlled not only by the programmer, is a source of use-after-free.
- Solution 2 — UObject: an explicitly separated category of objects for which the engine takes on automatic management and infrastructure integration; the rest of C++ remains "ordinary" and free of these overheads.
- New problem from this choice: the universal editor and other infrastructure must "know" the structure of absolutely any future class — but C++ erases this information after compilation.
- Solution 3 — Reflection via UHT and macros: a separate build step generates a runtime description of the class structure from macro-annotated source C++ code.
- The opportunity this opens: knowing the graph of UPROPERTY references between objects, the engine can automatically find unreachable objects.
- Solution 4 — Garbage Collector: a periodic, schedule-controlled traversal of this graph, freeing unreachable UObjects.
If you memorize five facts separately — "Unreal is a framework," "there is UObject," "there is Reflection," "there is GC" — you will know an API. If you hold in your head precisely the chain of dependencies — you will be able to take any new, unfamiliar engine system (Gameplay Ability System, Niagara, Enhanced Input) and ask the same question: "what problem of the previous layer does this system solve, and what new constraint does it in turn create?" — and it will work even for systems Epic adds to the engine after you finish reading this encyclopedia.
Impact on Blueprint
Blueprint — Unreal's visual programming language — is not a separate, independently built system on top of C++. It directly feeds on (in a good sense) the Reflection infrastructure described above: when UHT generates a runtime description of your class from UPROPERTY/UFUNCTION, the Blueprint editor uses exactly that same description to show your C++ field as a configurable pin on a node or your C++ function as a callable node in the graph. Blueprint "knows" about your class through no separate path — it sees exactly the same runtime structure description that the GC, the Details panel editor, and the serialization system see. This explains a practical consequence that would otherwise look like an arbitrary rule: if you want a designer to see your field or function in Blueprint, the only way is the same Reflection mechanism (UPROPERTY(BlueprintReadWrite), UFUNCTION(BlueprintCallable)), not some separate "Blueprint API."
05When to reason in these categories — and when it is overkill
| Worth explicitly tracing the chain "problem → constraint → solution" | Not worth it — the reasoning is unnecessary |
|---|---|
| You are designing a new engine system/plugin and are unsure whether a class should be a UObject descendant or an ordinary C++ class | You are using an existing, well-established engine class (for example, UStaticMeshComponent) for its intended purpose |
| You see an unfamiliar macro or specifier and want to understand its architectural meaning, not just copy it from a tutorial | The task is fully solved by a standard, documented combination of existing systems |
| You are explaining to a newcomer on the team why the project is done this way and not another | Changes within a single function with no architectural consequences |
This is the only adaptation of the "when to use / when not to use" section for a topic that has no single function with a signature — here "use" means "applying this way of reasoning," not "calling a specific API."
How this can be abused
The way of thinking itself also has a cost, and it can be paid in vain. Running the full "problem → constraint → solution" chain for every small edit — for example, stopping to ponder architectural reasons before changing a number in an existing, long-established component setting — is not engineering rigor, but analysis paralysis: time that could have been spent on the actual task goes into rebuilding reasoning that the Epic team, and most likely your own team as well, already did long ago. A sign that the reasoning has gone off track is if it takes more time than the code edit itself, and the result still coincides with the obvious, standard solution.
| Pros of inversion of control | Cons | Cost |
|---|---|---|
| The same engine is reused across thousands of different projects without rewriting infrastructure; guaranteed correct initialization order for all projects at once | The developer cannot choose at their own discretion when exactly to call BeginPlay or Tick — only fill these points with their code |
The need to study in advance which extension points exist at all and in what order the engine calls them — instead of writing an arbitrary scenario from scratch |
How Epic itself uses it
A telling fact: even the Unreal Engine editor itself is not a separate program written outside this architecture, but the same kind of Unreal application, built on the same framework as your game. Classes like UCharacterMovementComponent, responsible for character movement, have no separate "privileged" way of getting control every frame — they just as well override TickComponent, the same extension point available to your own component. When you open the source code of this class (a useful skill, covered separately in other encyclopedia articles) and see the familiar TickComponent signature, you are seeing not "engine magic," but the same mechanism you use yourself — just applied by Epic to a more complex task. This is a direct consequence of inversion of control: the engine has no backdoor, hidden from everyone else, to get control outside the system it itself provides to all developers.
06Common mistakes
A beginner coming from the world of ordinary programs instinctively looks for an "entry point" and tries to write a sequential scenario for the whole game in one place — "first load the menu, then wait for a button press, then start the level." This mistake arises because their entire previous programming experience is built around a single entry point, and Unreal physically does not provide one — the framework expects the game state to be expressed through classes and explicit transitions between them (GameMode/GameState change the match state, UI reacts to events), not through a manually, imperatively written scenario. The danger is not that the code will not compile — the danger is the time lost searching for a nonexistent entry point instead of studying the specific life-cycle points that already fill that role.
A mid-level developer usually already knows that UPROPERTY should be written, but explains this necessity to themselves with the wrong reason — "so the designer can see the field in the editor" — and therefore sometimes skips the macro for fields that the "designer doesn't need," including pointers to other UObjects. The danger lies precisely in this incorrect mental model: the real reason is visibility to the Garbage Collector, and editor visibility is only a side effect of the same Reflection mechanism. A skipped UPROPERTY on a "minor," in the developer's opinion, pointer is a direct path to use-after-free that may not manifest for months, until the GC deletes the object at an unlucky moment.
A senior developer does not ask "how do I make this work" — they ask "which extension point has the framework already provided for this, and why is it built this way and not another." The difference between these two questions is not abstract — it is easiest to see on one concrete task.
Task: add an inventory to the game. A beginner thinks concretely: "I need an inventory — so I need a UInventoryComponent class with an array of items inside," then goes looking for a ready-made tutorial specifically for this task and copies the found solution. The problem is not that the solution will necessarily be wrong — the problem is that the beginner does not understand why it is built this way, and therefore will not be able to adapt it independently when requirements change slightly (for example, the inventory must survive the character's death).
A senior does not look for an inventory tutorial — they walk through the chain of already known causes, exactly the way this article breaks it down:
- The inventory data must survive the character's death, but the
Pawnitself is destroyed on death — meaning the inventory physically cannot be stored in it. From the article about the Gameplay Framework, it is already known thatPlayerStateexists precisely for this case — it is specifically designed to live longer than the character's particular body. - New problem: how to store the list of items inside
PlayerState? From the article about containers, it is already known thatTArrayis the usual choice where element order matters, unlikeTMap, which is optimized for key lookup rather than order of traversal. - New problem: how should an item reference its immutable characteristics (damage, weight, icon) separately from its mutable state (current quantity, durability)? From the article about the Data Driven approach, it is already known that immutable item data is the job of a separate
DataAsset, while mutable state remains an ordinary field in the inventory slot structure itself, without duplicating the asset's data. - New problem: how should this list synchronize over the network without sending the entire inventory when a single item changes? From the article about replication, the general rule is already known — replicate the minimum sufficient to reconstruct the state, not the entire object; for arrays, the engine has a separate mechanism specifically designed for this task of efficient replication.
A senior has not memorized "how to make an inventory" as a separate fact — they assembled the solution from four cause-and-effect chains they had already understood earlier, each of which was once also an answer to the question "what problem does this solve." Faced with any new, unfamiliar engine system (Gameplay Ability System, Niagara, Enhanced Input), they look for exactly this same pattern: what problem of the previous layer does this system solve, and what new constraint does this system in turn create — instead of memorizing the API as a list of independent facts.
07Practice
SpawnActor / BeginPlay: who calls whom in each of the two cases, and why are these different directions of call?Show the expected line of reasoning
SpawnActor — you call an engine function: control is with your code; the engine behaves here like an ordinary library. BeginPlay — the engine calls your function at a point in the life cycle that it has predefined: control is with the framework; inversion of control in action. It is important to be able to determine for any engine function which of these two categories it falls into — this is the foundation for understanding the architecture of literally any Unreal system.
Show an example of the expected line of reasoning (not a ready answer)
The expected form of the answer is not a fact, but reasoning following the pattern of this article: "previously, input was likely handled directly by checking the pressed key in code — this creates problem X (for example, the inability to remap keys without editing the code). The new system likely introduces an intermediate level of abstraction Y, which in turn adds constraint Z (additional configuration instead of a single line of code)." The very fact that you try to formulate a hypothesis BEFORE reading the topic, not after — is the very "engineering thinking" this article teaches.
08Frequently asked questions
Because Reflection and GC in managed languages are designed for the general case — they do not give control over WHEN exactly the garbage collector pause happens, and a real-time engine critically needs predictability of every single frame (section 6). Unreal solves this task differently: it takes a language (C++) that in principle imposes no GC at all, and adds its own, schedule-controlled collector only for one clearly separated category of objects (UObject), leaving all the rest of the low-level engine (math, containers, render code) completely free of these overheads. A managed language does not allow such selectivity — in it, absolutely everything you create is under GC control.
No, and that is a deliberate architectural decision, not an oversight (section 7). Simple data structures without the need for GC, the editor, or serialization (a mathematical vector, a helper utility structure used only inside a single function) most often remain ordinary C++ classes/structs — they do not pay the price of Reflection and GC because they do not need it. The decision is always made by asking "does this class need integration with the engine infrastructure," not by default.
No — you fully control the execution order INSIDE your own functions (what happens inside your BeginPlay is up to you, line by line). You only do not control WHEN the framework calls these functions relative to other parts of the engine and other of your own classes — and for that, the framework has explicitly documented ordering guarantees (for example, "BeginPlay is guaranteed to be called after all of the actor's components are registered"), which you can and should rely on, instead of trying to bypass the system with artificial delays.
No — accessing a field's value like Health = 100.f; in compiled code remains an ordinary, direct memory access operation by offset, exactly as fast as for any ordinary C++ field. Reflection's overhead appears not in ordinary read/write of a field from C++ code, but in operations that SPECIFICALLY use the runtime structure description — iterating over all fields of a class by name (for example, when serializing to a save file), building the editor's Details panel, looking up a function by name to call from Blueprint. Ordinary everyday C++ game logic does not pay this price.
No, and the architecture broken down in this article explains why: Blueprint technically cannot exist without the C++ layer it visualizes (section 11) — the very Reflection information the Blueprint editor sees is generated from C++ classes annotated with UPROPERTY/UFUNCTION. The established practice in the industry and at Epic itself (see the Lyra project) — heavy, frequently executed logic and foundational systems are written in C++ for performance and control, while Blueprint is used on top of ready-made C++ classes for quick tuning of specific values, wiring up events, and iteration by a designer without involving a programmer for every little thing.
09What the reader should start noticing
After this article, an unfamiliar macro or specifier in someone else's code stops being a reason to simply copy it from a tutorial — instead, a reflex appears to ask which engine infrastructure (GC, editor, Blueprint, serialization) it connects to, and whether that price has been paid for nothing.
A pointer to a UObject without UPROPERTY in someone else's or your own code now reads not as a minor shortcoming, but as a potential use-after-free — because after the section on the Garbage Collector it is clear: invisibility to the GC is not an abstract risk, but a direct consequence of how the reference graph traversal works.
And when encountering any new, not yet studied engine system (Niagara, Mass Entity, Chaos), the natural first question becomes not "how do I use this," but "what problem of the previous architecture layer does it solve, and what new constraint does it create" — the very way of thinking this article describes as its main lesson, not a set of five facts.
10Summary
- Unreal Engine is a framework, not a library: it owns the program's main loop, and your code is a set of extension points called by the engine at predefined places (inversion of control), not a set of functions you call yourself and in the order you choose.
- Inversion of control is not aesthetics, but the only way to make one and the same engine reusable across projects with different game logic: the engine guarantees one correct initialization order for any project, and your responsibility narrows down to filling in already safe extension points.
- C++ was chosen as the implementation language because of the tight frame budget: managed languages with unpredictable GC introduce pauses a real-time engine cannot afford — but pure C++ with manual
new/deletedoes not scale to thousands of mutually referencing objects whose lifetime is controlled not only by the programmer, but also by the editor, level loading, and the network. - UObject is not "the base class for everything," but a deliberately drawn boundary: on one side — objects for which the engine infrastructure (GC, editor, serialization, networking) takes responsibility and overhead; on the other — ordinary C++ that does not pay this price because it does not need it.
- Reflection exists because the engine's universal infrastructure (the editor, serialization) needs to "know" the structure of absolutely any class, including ones not yet written, while ordinary C++ erases this information after compilation — the Unreal Header Tool restores it in a separate build step, generating a runtime description of the class from UCLASS/UPROPERTY/UFUNCTION.
- The Garbage Collector became possible precisely thanks to Reflection, not independently of it: knowing via UPROPERTY which fields are references to other UObjects, the engine can build a reachability graph and free unreachable objects on a controlled, predictable schedule, not at an arbitrary moment.
- Blueprint has no source of knowledge about your classes separate from C++ — it reads exactly the same Reflection description that the GC and the Details panel editor read, so the only way to make a field or function available to a designer is the same UPROPERTY/UFUNCTION used by the rest of the infrastructure.
- These are not five isolated facts, but a single chain of cause and effect, and it is the chain you should remember: "what problem of the previous layer does this system solve, and what new constraint does it in turn create" — a question applicable to any engine system you have not studied yet, including those that will appear in Unreal after you finish this encyclopedia.
When you encounter an unfamiliar engine system, do not ask "how do I use this" — ask "what problem of the previous architecture layer does it solve, and what new problem does it create with that solution." Framework solved the infrastructure problem at the price of inversion of control. UObject solved the use-after-free problem at the price of a boundary between "expensive" and "cheap" parts of C++. Reflection solved the type erasure problem at the price of macros and an extra build step. GC solved the reference graph safety problem at the price of periodic overhead. There is no magic in Unreal's architecture — there is only a price you have not found yet, paid by the previous solution.
Material prepared for UE C++ Academy. Original article — uecppacademy.com. If this material helped you understand Unreal Engine — you can support the project's development.
© 2026 UE C++ Academy. All rights reserved. For copyright questions or technical issues — support@uecppacademy.com