Skip to content

Unreal Engine: code architecture

How to structure C++ and Blueprint gameplay code, data, input, UI and multiplayer so that it stays changeable as the project grows.

Entries are sorted by score from 1 to 10 (criteria): 9โ€“10 start here or strongly recommended, 6โ€“8 recommended, 1โ€“5 further reading or conditional.

Adopted references

  • 9 Gameplay Framework (Unreal Engine documentation): the baseline for gameplay code. What the game instance, game mode, game state, player state, controllers and pawns are for, and how they relate.
  • 9 Epic C++ Coding Standard: naming, class layout, formatting and C++ language rules. Mandatory at Epic.
  • 8 Networking Overview: the client-server model, replication, RPCs, network roles and a list of networking tips.
  • 8 Exposing C++ to Blueprints: when to use C++ or Blueprint, and how to design a Blueprint-friendly C++ API.
  • 6 Blueprint Best Practices: Level Blueprints versus Blueprint classes, functions versus macros, and communication between Blueprints.

Key rules

Code and gameplay framework

  • 9 UNREAL-1 Hold UObject references that must keep their target alive in UPROPERTY members, preferably TObjectPtr, and use TWeakObjectPtr for references that must not. The garbage collector can't see raw pointers, so their targets can be collected and the pointers left dangling. (Unreal Object Handling, Object Pointers)
  • 8 UNREAL-2 Put match rules in the game mode, which exists only on the server, state that all players need in the game state, per-player state in the player state, and anything that must survive a level change in the game instance or its subsystems. (Gameplay Framework, Game Mode and Game State)
  • 7 UNREAL-3 Write core systems, high-frequency logic and data-heavy work in C++ base classes, and expose a small API that designers extend in Blueprint subclasses. Move a Blueprint's logic into C++ when profiling or its complexity calls for it. (Exposing C++ to Blueprints, Blueprint Best Practices)
  • 7 UNREAL-4 Put game-wide services in subsystems (UGameInstanceSubsystem, ULocalPlayerSubsystem, UEngineSubsystem or UEditorSubsystem) instead of adding them to a custom game instance or overriding engine classes. (Programming Subsystems)
  • 7 UNREAL-23 Don't poll for changes on Tick: run occasional logic from events, delegates or timers, give logic that must repeat but not every frame a tick interval, and turn ticking off on Actors and components that don't need it. Spread expensive work, such as spawning many Actors, over several frames, and move heavy computation off the game thread with the Tasks System rather than your own threads. (Unreal Engine, Common Memory and CPU Performance Considerations, Actor Ticking, Gameplay Timers, Tasks System)
  • 5 UNREAL-24 Represent statuses, object types and gameplay events as hierarchical Gameplay Tags of the form Movement.Mode.Swimming, registered in .ini tag lists or as native tags in C++. The Gameplay Ability System uses them to track each Actor's status. (Unreal Engine, Using Gameplay Tags, Understanding the Gameplay Ability System)
  • 5 UNREAL-6 Use the Gameplay Ability System for games built around many abilities, attributes and status effects, especially multiplayer ones. It replicates abilities and attributes, and supports prediction. (Understanding the Gameplay Ability System)
  • 5 UNREAL-25 Model AI and other state-driven logic, such as game flow, in StateTree, Epic's general-purpose hierarchical state machine, or, for AI, in Behavior Trees with a Blackboard. This applies GAMEDEV-21. (Unreal Engine, StateTree Overview, Behavior Trees)

Data and save games

  • 7 UNREAL-26 Put designer-tunable data in Data Tables, whose rows are C++ structs and which designers can import from CSV or JSON files, or in Data Assets, and make content that the Asset Manager loads on demand a Primary Data Asset. This applies GAMEDEV-3. (Unreal Engine, Data Driven Gameplay Elements, Asset Management)
  • 7 UNREAL-27 Save games through your own USaveGame subclasses, with separate classes for globally unlocked features and for each playthrough's data, and save with AsyncSaveGameToSlot during play. Epic recommends asynchronous saving because it avoids a frame-rate hitch and a possible certification issue on some platforms. Versioning and keeping the last good save are GAMEDEV-10 and GAMEDEV-11. (Unreal Engine, Saving and Loading Your Game)

Blueprints, input and UI

  • 6 UNREAL-28 Choose how Blueprints communicate by the relationship between them: a direct reference for one Actor talking to one specific other, an event dispatcher to tell any number of listeners that something happened, and a Blueprint Interface to call the same function on unrelated classes that each respond in their own way. (Unreal Engine, Blueprint Communication Usage, Blueprint Interface)
  • 6 UNREAL-29 Handle player input with Enhanced Input: an Input Action for each thing the player can do, Input Mapping Contexts that you add, remove and prioritize as the player's situation changes, and Player Mappable Input Configs for control presets. Enhanced Input is on by default, and it supports remapping controls at run time, which is part of GAMEDEV-18. (Unreal Engine, Enhanced Input)
  • 5 UNREAL-30 Keep game logic out of UMG widgets: give widgets their data through viewmodels and View Bindings (the UMG Viewmodel plugin, in Beta), which update a widget only when a value changes, and set the Property Binding Rule to Prevent so that nobody adds legacy property bindings. For layered menus that must work with a gamepad, build on the Common UI plugin. (Unreal Engine, UMG Viewmodel, Common UI Plugin)

Accessibility

  • 5 UNREAL-45 If players need a screen reader, turn on Unreal's accessibility support with Accessibility.Enable=1, set the Accessibility options of each UMG widget, such as Accessible Behavior, and choose how it's read: by third-party screen readers on Windows and VoiceOver on iOS, or by the Slate Screen Reader plugin, which reads focused Slate and UMG widgets aloud with the engine's text-to-speech. Epic marks screen reader support as Experimental, and the Text To Speech plugin supports only English, so test it on each target platform before you rely on it. This applies A11Y-9. (Unreal Engine, Supporting Screen Readers, Unreal Engine, Blind Accessibility Features Overview)

Multiplayer

How to enforce

Tools that check the key rules above automatically, in CI, the IDE or a commit hook. "Partly" means the tool covers only some of what the rule asks.