Chapter 07

References & Dependencies

Hard versus soft references, how hard ones get created without you noticing, what they cost, and the tools for cutting coupling.

In this chapter

  1. Hard vs. Soft
  2. How Hard References Get Created
  3. TObjectPtr vs. Raw Pointers
  4. The Cost — Transitive and Eager
  5. Reducing Coupling
1

Hard vs. Soft

Hard reference

Loads its target into memory whenever the referencing object loads. No loading code, no choice in the matter.

Soft reference

Just a path. Costs nothing until you explicitly resolve it.


2

How Hard References Get Created

In C++

A raw pointer not wrapped in UPROPERTY isn't "a hard reference done safely" — it's a dangling-pointer bug waiting to happen, because GC can collect the target out from under it.

In Blueprint


3

TObjectPtr vs. Raw Pointers

TObjectPtr is the modern idiom for hard UObject references. At runtime it behaves like a raw pointer and is pointer-sized in a cooked build, so there's no runtime cost.

The difference is editor-only: access-tracking hooks and clearer intent. Purely a cooked-versus-editor distinction.


4

The Cost — Transitive and Eager

Hard references load transitively and eagerly. If a character hard-references a weapon that hard-references a mesh, a sound, a VFX system and an ability set, then loading the character drags all of it into memory — whether or not you use it that frame.

On an interconnected encounter, that reference graph balloons fast. Circular hard dependencies are especially dangerous.

The upside, and why they're described as simple, safe and predictable: the pointer is either valid or null, you never write loading code, and you can't dereference something that isn't loaded.

5

Reducing Coupling

ToolWhat it buys you
InterfacesDepend on a capability rather than a concrete class (Chapter 2)
Base-class referencesReference Actor or a shared base instead of a concrete type
Soft referencesTSoftObjectPtr / TSoftClassPtr plus async loading — the path costs nothing until resolved
Event DispatchersInvert the dependency direction, so the referencer doesn't hold the referenced (Chapter 13)
Data Tables / Data AssetsData-driven config decoupling (Chapter 8)
Reference ViewerThe editor tool for auditing what your core Blueprints actually pull in

The soft-reference machinery here is the same machinery that underlies Asset Bundles — see Chapter 9.

Point the Reference Viewer at your player, game mode and HUD Blueprints first. Those are the ones most likely to have quietly accumulated a dependency graph nobody intended.
← Chapter 6 ↑ Index Chapter 8 →