<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:media="http://search.yahoo.com/mrss/">
  <channel>
    <title>unreal-cpp on stillcooking.dev</title>
    <link>https://stillcooking.dev/en/tags/unreal-cpp/</link>
    <description>Personal portfolio and technical notes</description>
    <generator>Hugo</generator>
    <language>en-US</language>
    
    <copyright>© 2026 stillcooking.dev — CC BY 4.0, https://creativecommons.org/licenses/by/4.0/</copyright>
    <lastBuildDate>Thu, 13 Aug 2026 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://stillcooking.dev/en/tags/unreal-cpp/index.xml" rel="self" type="application/rss+xml" />
    
    <item>
      <title>ShouldCreateSubsystem and the subsystem class hierarchy</title>
      <link>https://stillcooking.dev/en/topics/unreal-engine/gameplay-framework/should-create-subsystem-picks-the-class/</link>
      <pubDate>Thu, 13 Aug 2026 00:00:00 +0000</pubDate>
      
      <guid isPermaLink="true">https://stillcooking.dev/en/topics/unreal-engine/gameplay-framework/should-create-subsystem-picks-the-class/</guid>
      <description>The subsystem collection asks each non-abstract class&amp;rsquo;s CDO whether to create an instance. A subclass does not automatically replace its parent; both can exist side by side. This explains how to move the implementation into Blueprint, how to keep a C++ fallback when the child is missing, and why GetSubsystem&lt;T&gt;() can still find the derived instance.</description>
      <content:encoded><![CDATA[<p><code>ShouldCreateSubsystem</code> reads like an on/off switch: return <code>false</code>, and the subsystem is not created. That is how it behaves in its most common use, but that is only one use of a broader mechanism. The method decides whether an instance of each candidate class is created. Across a hierarchy, those individual decisions determine which implementations end up in the collection.</p>
<p>The difference only shows up once the hierarchy has more than one level, which happens as soon as someone creates a Blueprint child of a subsystem written in C++.</p>
<p>I covered the lifecycle contract and where each collection starts in a separate post: <a href="/en/topics/unreal-engine/gameplay-framework/subsystem-lifecycle-init-order">Subsystem and manager actor lifecycles</a>. Here, I&rsquo;m focusing on one specific part: the loop that picks the classes.</p>
<h2 id="a-subclass-does-not-replace-its-parent">A subclass does not replace its parent</h2>
<p>The collection gathers derived classes in a single call and runs <strong>every one</strong> of them through the same procedure (<code>Engine/Private/Subsystems/SubsystemCollection.cpp:209</code>):</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="n">TArray</span><span class="o">&lt;</span><span class="n">UClass</span><span class="o">*&gt;</span> <span class="n">SubsystemClasses</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="n">GetDerivedClasses</span><span class="p">(</span><span class="n">BaseType</span><span class="p">,</span> <span class="n">SubsystemClasses</span><span class="p">,</span> <span class="nb">true</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="k">for</span> <span class="p">(</span><span class="n">UClass</span><span class="o">*</span> <span class="nl">SubsystemClass</span> <span class="p">:</span> <span class="n">SubsystemClasses</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">AddAndInitializeSubsystem</span><span class="p">(</span><span class="n">SubsystemClass</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div></div>
<p>There is no selection of the most-derived class here, no collapsing of the hierarchy, no rule that the child wins over the parent. The question is asked separately of each entry’s own CDO (<code>SubsystemCollection.cpp:331</code>):</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="k">const</span> <span class="n">USubsystem</span><span class="o">*</span> <span class="n">CDO</span> <span class="o">=</span> <span class="n">SubsystemClass</span><span class="o">-&gt;</span><span class="n">GetDefaultObject</span><span class="o">&lt;</span><span class="n">USubsystem</span><span class="o">&gt;</span><span class="p">();</span>
</span></span><span class="line"><span class="cl"><span class="k">if</span> <span class="p">(</span><span class="n">CDO</span><span class="o">-&gt;</span><span class="n">ShouldCreateSubsystem</span><span class="p">(</span><span class="n">Outer</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">USubsystem</span><span class="o">*</span> <span class="n">Subsystem</span> <span class="o">=</span> <span class="n">NewObject</span><span class="o">&lt;</span><span class="n">USubsystem</span><span class="o">&gt;</span><span class="p">(</span><span class="n">Outer</span><span class="p">,</span> <span class="n">SubsystemClass</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">    <span class="n">SubsystemMap</span><span class="p">.</span><span class="n">Add</span><span class="p">(</span><span class="n">SubsystemClass</span><span class="p">,</span> <span class="n">Subsystem</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">    <span class="c1">// ...
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span></span></span></code></pre></div></div>
<p>The consequence is straightforward and easy to miss: a Blueprint child of a C++ class joins the parent as a <strong>second, independent instance</strong>. The base implementation returns <code>true</code> (<code>Subsystem.h:61</code>), so if nobody has overridden the method, two instances live in the collection. One of the C++ class, one of the Blueprint class. Both have run <code>Initialize</code>, both carry their own state, and neither knows about the other.</p>
<div class="callout callout--warning">
  <div class="callout__title">Warning</div>
  Creating a Blueprint child of a subsystem takes two clicks and no C++ at all. From that point on, every counter, cache, and handler in that subsystem exists in duplicate. The engine reports nothing, because as far as the collection is concerned these are two different classes and two valid entries in <code>SubsystemMap</code>.
</div>

<p>Two filters run before that question is asked. The first rejects abstract classes (<code>:318</code>), the second rejects non-authoritative ones (<code>:324</code>):</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="c1">// Do not create instances of classes that aren&#39;t authoritative.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="k">if</span> <span class="p">(</span><span class="n">SubsystemClass</span><span class="o">-&gt;</span><span class="n">GetAuthoritativeClass</span><span class="p">()</span> <span class="o">!=</span> <span class="n">SubsystemClass</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="k">return</span> <span class="k">nullptr</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div></div>
<p>The second one says something about intent. <code>GetAuthoritativeClass</code> filters out the intermediate classes produced when Blueprints are recompiled, which means Epic hardened this path for Blueprint classes. A Blueprint subsystem is a scenario the engine anticipates.</p>
<h2 id="the-switch-false-in-c-true-in-blueprint">The switch: <code>false</code> in C++, <code>true</code> in Blueprint</h2>
<p>The question is asked separately of every CDO, and Blueprint defaults <strong>live on the CDO</strong> of their class. The same flag can therefore hold a different value at each level of the hierarchy, which turns it into a switch between implementation layers:</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="n">UCLASS</span><span class="p">(</span><span class="n">Blueprintable</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="k">class</span> <span class="nc">MYGAME_API</span> <span class="nl">UMySubsystem</span> <span class="p">:</span> <span class="k">public</span> <span class="n">UGameInstanceSubsystem</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">GENERATED_BODY</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="k">protected</span><span class="o">:</span>
</span></span><span class="line"><span class="cl">    <span class="cm">/** Read from the CDO only - set to true in the Blueprint child that implements this. */</span>
</span></span><span class="line"><span class="cl">    <span class="n">UPROPERTY</span><span class="p">(</span><span class="n">EditDefaultsOnly</span><span class="p">,</span> <span class="n">Category</span> <span class="o">=</span> <span class="s">&#34;Config&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">    <span class="kt">bool</span> <span class="n">bShouldCreateSubsystem</span> <span class="o">=</span> <span class="nb">false</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">    <span class="k">virtual</span> <span class="kt">bool</span> <span class="nf">ShouldCreateSubsystem</span><span class="p">(</span><span class="n">UObject</span><span class="o">*</span> <span class="n">Outer</span><span class="p">)</span> <span class="k">const</span> <span class="k">override</span>
</span></span><span class="line"><span class="cl">    <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="k">return</span> <span class="n">Super</span><span class="o">::</span><span class="n">ShouldCreateSubsystem</span><span class="p">(</span><span class="n">Outer</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="n">bShouldCreateSubsystem</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">};</span></span></span></code></pre></div></div>
<p>With <code>false</code> on the C++ side and <code>true</code> in the Blueprint class defaults, exactly one instance ends up in the collection. The C++ class becomes a skeleton: it defines the interface, the <code>BlueprintImplementableEvent</code> declarations, and everything Blueprint cannot declare on its own, while the implementation lives one level below.</p>
<p>This works because <code>ShouldCreateSubsystem</code> runs on the CDO before an instance exists, which means it runs on the object that holds the default values stored in the Blueprint asset. That is also why the flag is marked <code>EditDefaultsOnly</code>. The value is read from the defaults and nowhere else, so per-instance editing changes nothing.</p>
<div class="callout callout--note">
  <div class="callout__title">Note</div>
  The result of <code>Super::ShouldCreateSubsystem(Outer)</code> has to feed <strong>into the condition</strong>. The base implementation returns <code>true</code> (<code>Subsystem.h:61</code>), so calling it and discarding the result looks harmless. In classes derived from <code>UWorldSubsystem</code> the override checks <code>DoesSupportWorldType</code>, and skipping it allows the subsystem to be created in editor worlds.
</div>

<h2 id="getsubsystemt-finds-the-child-anyway"><code>GetSubsystem&lt;T&gt;()</code> finds the child anyway</h2>
<p>Instances live in a <code>TMap&lt;UClass*, USubsystem*&gt;</code> keyed by the <strong>concrete</strong> class. The natural conclusion is that querying for the base class will not find an instance of a derived one, and that conclusion is wrong. <code>GetSubsystemInternal</code> has a fallback (<code>SubsystemCollection.cpp:66</code>):</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="n">USubsystem</span><span class="o">*</span> <span class="n">SystemPtr</span> <span class="o">=</span> <span class="n">SubsystemMap</span><span class="p">.</span><span class="n">FindRef</span><span class="p">(</span><span class="n">SubsystemClass</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="k">if</span> <span class="p">(</span><span class="n">SystemPtr</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="k">return</span> <span class="n">SystemPtr</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="k">else</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="k">const</span> <span class="n">FSubsystemArray</span><span class="o">&amp;</span> <span class="n">SystemPtrs</span> <span class="o">=</span> <span class="n">FindAndPopulateSubsystemArrayInternal</span><span class="p">(</span><span class="n">SubsystemClass</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">    <span class="k">if</span> <span class="p">(</span><span class="n">SystemPtrs</span><span class="p">.</span><span class="n">Subsystems</span><span class="p">.</span><span class="n">Num</span><span class="p">()</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">    <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="k">return</span> <span class="n">SystemPtrs</span><span class="p">.</span><span class="n">Subsystems</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div></div>
<p>A miss in the map triggers an <code>IsChildOf</code> sweep and returns the first hit. So <code>GetSubsystem&lt;UMySubsystem&gt;()</code> with the base class as the parameter returns the Blueprint child instance, even though nothing is stored under the base class key.</p>
<p>Without that fallback the switch would make no sense. Every piece of C++ that queries the subsystem by its own base class would stop seeing it the moment the implementation moved into Blueprint.</p>
<div class="callout callout--insight">
  <div class="callout__title">Insight</div>
  The fallback returns <code>Subsystems[0]</code>, the first hit in the array. With two instances alive (a parent that never overrode the method, plus a child), the order in that array decides the result. That is one more reason for the hierarchy to have exactly one winner.
</div>

<p>Listing every instance at once takes a separate accessor. In 5.7 it is called <code>GetSubsystemArrayCopy</code> and returns by value, both on the collection itself (<code>Public/Subsystems/SubsystemCollection.h:139</code>) and on the <code>UGameInstance</code> wrapper (<code>Classes/Engine/GameInstance.h:463</code>).</p>
<h2 id="the-flagless-variant-yielding-to-subclasses">The flagless variant: yielding to subclasses</h2>
<p>The flag has one unpleasant property. When the Blueprint child is gone, whether it was deleted, moved, or simply never loaded in time, <code>false</code> on the C++ side means <strong>nothing</strong> is created. The subsystem disappears entirely, including the part that was written in C++ and had nothing to do with Blueprint.</p>
<p>The condition can be phrased differently: let the class step aside, provided there is someone to step aside for.</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="kt">bool</span> <span class="n">UMySubsystem</span><span class="o">::</span><span class="n">ShouldCreateSubsystem</span><span class="p">(</span><span class="n">UObject</span><span class="o">*</span> <span class="n">Outer</span><span class="p">)</span> <span class="k">const</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">Super</span><span class="o">::</span><span class="n">ShouldCreateSubsystem</span><span class="p">(</span><span class="n">Outer</span><span class="p">))</span>
</span></span><span class="line"><span class="cl">    <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="k">return</span> <span class="nb">false</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">    <span class="c1">/// @Note: The collection instantiates every non-abstract subclass, so a Blueprint child
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>    <span class="c1">///        would live alongside this one. Yield so that only the most-derived class is created.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>    <span class="n">TArray</span><span class="o">&lt;</span><span class="n">UClass</span><span class="o">*&gt;</span> <span class="n">DerivedClasses</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="n">GetDerivedClasses</span><span class="p">(</span><span class="n">GetClass</span><span class="p">(),</span> <span class="n">DerivedClasses</span><span class="p">,</span> <span class="cm">/*bRecursive*/</span> <span class="nb">true</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">    <span class="k">return</span> <span class="n">DerivedClasses</span><span class="p">.</span><span class="n">Num</span><span class="p">()</span> <span class="o">==</span> <span class="mi">0</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div></div>
<p>In the normal case the outcome is the same, since a child exists and the parent steps aside. The failure looks different though: a missing child leaves a working C++ instance instead of an empty slot. There is also no flag to forget to set in a new Blueprint&rsquo;s defaults.</p>
<p>I use this variant in a production subsystem, and I have tested it in PIE. With the Blueprint child present, exactly one instance is alive; with the child removed, the C++ instance is. I have not tested it in a packaged build, so that behavior remains an inference from the mechanism rather than an observed result.</p>
<p>There are two limits, and both follow directly from this implementation.</p>
<p><strong>Two children mean two instances.</strong> Each of them sees zero descendants and each concludes that it is the most-derived one. This case cannot be resolved inside the method, which leaves a convention: exactly one Blueprint child per class.</p>
<p><strong>A single permanently loaded C++ subclass disables the base class for good.</strong> A test class in an Editor module is enough. It is compiled, so it sits in memory from startup, so the parent yields to it in every editor session. In practice this means a test module must not derive from such a subsystem, and the test double has to be built on a plain <code>UObject</code> acting as a listener. This trap is worse than two Blueprint children, because nothing about it is visible in the assets. It lives in test code that nobody associates with runtime.</p>
<h2 id="common-mistakes">Common mistakes</h2>
<div class="table-wrap">
  <table>
    <thead>
      <tr>
        <th>Mistake</th>
        <th>Effect</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><code>Super::ShouldCreateSubsystem(Outer);</code> on its own line, result discarded</td>
        <td>The parent condition does nothing; in <code>UWorldSubsystem</code> the subsystem enters editor worlds</td>
      </tr>
      <tr>
        <td><code>EditAnywhere</code> instead of <code>EditDefaultsOnly</code> on the flag</td>
        <td>Implies per-instance editing, while the value is read from the CDO and nowhere else</td>
      </tr>
      <tr>
        <td>A Blueprint child with no overridden condition on the C++ side</td>
        <td>Two live instances, split state, and <code>GetSubsystem&lt;T&gt;()</code> returning the first hit in the array</td>
      </tr>
      <tr>
        <td>The flag set to <code>false</code> and a child that never loads in time</td>
        <td>Zero instances — <a href="/en/topics/unreal-engine/gameplay-framework/blueprint-subsystem-missing-in-packaged-build">a separate case, covered here</a></td>
      </tr>
    </tbody>
  </table>
</div>
<p>The last of those cannot be reproduced in the editor. It only surfaces in a packaged build.</p>
<h2 id="verification">Verification</h2>
<p>The number and classes of live instances, in one console command:</p>
<div class="highlight" data-lang="text">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">obj list class=MySubsystem</span></span></code></pre></div></div>
<p>A query for the base class covers derived classes, so it shows the parent and the children at once, broken down by class. Two rows instead of one reveal the duplication described in the table above; a row for a <code>_C</code> class means the switch worked and the Blueprint implementation is the one running.</p>
<p>Each CDO decision is in the log once the category’s log level is raised:</p>
<div class="highlight" data-lang="text">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">-LogCmds=&#34;LogSubsystemCollection VeryVerbose&#34;</span></span></code></pre></div></div>
<div class="highlight" data-lang="log">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><pre tabindex="0" class="ue-log"><code><span class="ue-log__line ue-log__line--verbose"><span class="ue-log__cat">LogSubsystemCollection</span>: <span class="ue-log__sev ue-log__sev--veryverbose">VeryVerbose</span>: <span class="ue-log__msg">Subsystem does not exist, but CDO choose to not create (MySubsystem)</span>
</span></code></pre>
</div>
<p>That line means the class was on the list and refused. Its <strong>absence</strong>, together with a missing instance, means something entirely different: the class was not on the list, so nobody asked it. Telling those two states apart is the only way to distinguish a working switch from a class that never loaded. At the default log level both of them look like silence, which is why the category’s log level has to be raised first.</p>
]]></content:encoded>
      
    </item>
    
    <item>
      <title>A tickable UObject — how to build one, what to keep in mind</title>
      <link>https://stillcooking.dev/en/topics/unreal-engine/gameplay-framework/tickable-uobject/</link>
      <pubDate>Thu, 30 Jul 2026 00:00:00 +0000</pubDate>
      
      <guid isPermaLink="true">https://stillcooking.dev/en/topics/unreal-engine/gameplay-framework/tickable-uobject/</guid>
      <description>How to build a base class for a ticking UObject in a UE project: the design decisions that matter, with the complete class available in StillCooking_Tools.</description>
      <content:encoded><![CDATA[<p>A <code>UObject</code> does not tick. It has no <code>PrimaryActorTick</code>, it belongs to no tick group, and the engine has no reason to visit it every frame. The standard answer is multiple inheritance: <code>UObject</code> plus <code>FTickableGameObject</code>. The catch is that inheritance alone does not give you a tick, only registration. Everything that determines <em>whether</em>, <em>when</em>, and <em>for how long</em> the object actually ticks is still yours to set up.</p>
<h2 id="what-ftickablegameobject-is">What <code>FTickableGameObject</code> is</h2>
<p><code>FTickableGameObject</code> is a plain C++ class from <code>Tickable.h</code> that you inherit from alongside <code>UObject</code>. Its constructor adds <code>this</code> to a pending queue (<code>Tickable.cpp:133-145</code>), and the object only moves into the real array at the next tick pass (<code>Tickable.cpp:67-95</code>). The destructor removes it from that array (<code>Tickable.cpp:147-152</code>), and the engine walks the array once per frame (<code>Tickable.cpp:167-208</code>). This is a separate track running alongside the <code>FTickFunction</code> machinery that actors and components use. It is not part of it.</p>
<p>The upside is that the object does not have to be in a world, does not have to be spawned, and has no transform. The price is that it also gets none of what the other track gives actors: no tick groups, no <code>AddTickPrerequisiteActor</code>, no <code>TickInterval</code>. The entire class declaration (<code>Tickable.h:134-210</code>) does not contain a single one of them. You either give up all three or build them by hand.</p>
<p>For an object tied to a world, the call sits in <code>UWorld::Tick</code> (<code>LevelTick.cpp:1792</code>), after <code>TG_PostPhysics</code> (<code>LevelTick.cpp:1749</code>) but before <code>TG_PostUpdateWork</code> (<code>LevelTick.cpp:1848</code>). An actor ticking in <code>TG_PostUpdateWork</code> sees the state this tick has already produced. An object with no world lands somewhere else: it ticks only after the loop over all worlds. The engine says so outright in the comment on the method (<code>Tickable.h:183</code>), and the call itself sits in <code>GameEngine.cpp:1947</code>.</p>
<h2 id="when-to-reach-for-this-and-when-not-to">When to reach for this, and when not to</h2>
<p><strong>Does this have to be an actor?</strong> If the object needs a transform, collision, replication, placement in a level, or tick groups, the answer is “actor” and the rest of this post does not apply. None of those can be bolted onto <code>FTickableGameObject</code>.</p>
<p><strong>Is the logic per-frame or event-driven?</strong> If it comes down to “in three seconds” or “every half second” and nothing in between, that is <code>FTimerManager</code>, not a tick. Polling state sixty times a second to respond once is a cost with no return.</p>
<p><strong>Should the object live exactly as long as the world?</strong> If so, the right answer is almost always <code>UTickableWorldSubsystem</code>: a ready, tested lifecycle, without a single line of what I describe below. Your own base class earns its place when you need <strong>multiple instances</strong> (a subsystem is one instance per class per owner by definition), or when a designer is meant to create subclasses in Blueprint, which a subsystem cannot do.</p>
<div class="callout callout--insight">
  <div class="callout__title">Insight</div>
  <code>UTickableWorldSubsystem</code> is the best possible source on this: it is Epic&rsquo;s own implementation of the pattern. The whole class fits in <code>WorldSubsystem.cpp:97-160</code>.
</div>

<h2 id="decision-one-when-you-register">Decision one: when you register</h2>
<p>The default answer: <strong>in the constructor</strong>. Inheritance is enough. The base constructor runs on its own, the object lands in the registry, no extra code.</p>
<p>And that is exactly what you must not do. The constructor documentation says so outright:</p>
<blockquote>
<p>If this is something like a UObject that could be created on a different thread (like for async loading), construct with a Never tick type and enable tick later.</p>
<p>— <code>Tickable.h:147</code> (UE 5.7)</p>
</blockquote>
<p>The base constructor in full:</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="c1">// UE 5.7 — Tickable.cpp:133-145
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">FTickableGameObject</span><span class="o">::</span><span class="n">FTickableGameObject</span><span class="p">(</span><span class="n">ETickableTickType</span> <span class="n">StartingTickType</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="k">if</span> <span class="p">(</span><span class="n">StartingTickType</span> <span class="o">!=</span> <span class="n">ETickableTickType</span><span class="o">::</span><span class="n">Never</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">    <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="c1">// It is only safe to create tickable game objects on the game thread, as otherwise there is a race condition between object initialize and the game thread tick
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>        <span class="c1">// If you hit this ensure, change the constructor to use FTickableGameObject(ETickableTickType::Never) and call SetTickableTickType after initialization
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>        <span class="n">ensure</span><span class="p">(</span><span class="n">IsInGameThread</span><span class="p">());</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">        <span class="c1">// Queue for creation, this can get called very early in startup
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>        <span class="n">FTickableStatics</span><span class="o">&amp;</span> <span class="n">Statics</span> <span class="o">=</span> <span class="n">GetStatics</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">        <span class="n">Statics</span><span class="p">.</span><span class="n">QueueTickableObjectForAdd</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="n">StartingTickType</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div></div>
<p>The base constructor runs <strong>before</strong> the body of the derived class constructor, <strong>before</strong> the archetype and Blueprint-class defaults are applied over the native ones, and <strong>before</strong> the owner has a chance to configure anything. Defaults are not applied until <code>FObjectInitializer::PostConstructInit</code> (<code>UObjectGlobals.cpp:4239</code>), the copy itself in <code>UObjectGlobals.cpp:4350</code>, and <code>PostInitProperties</code> runs later still (<code>UObjectGlobals.cpp:4427</code>) — all three after the C++ constructor chain. The next tick pass will call <code>GetTickableTickType()</code>, and then <code>Tick()</code>, on a half-configured object. On top of that, the CDO registers along with the instances, because the <code>FTickableGameObject</code> constructor does not check <code>IsTemplate()</code> or anything of the sort (<code>Tickable.cpp:133-145</code>).</p>
<p>The correct answer is to construct with an explicit “do not tick” and enable ticking later:</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="n">UTickableObject</span><span class="o">::</span><span class="n">UTickableObject</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">    <span class="o">:</span> <span class="n">FTickableGameObject</span><span class="p">(</span><span class="n">ETickableTickType</span><span class="o">::</span><span class="n">Never</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="c1">// Deliberately empty. Registering for tick here is exactly what Tickable.h forbids.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">}</span></span></span></code></pre></div></div>
<h2 id="decision-two-when-you-unregister">Decision two: when you unregister</h2>
<p>The default answer: <strong>in the destructor</strong>. And again it is too late. A <code>UObject</code> destructor runs long after the object stopped being useful, and in the meantime the engine is free to tick it.</p>
<p>The right place is an explicit method called by the owner, plus a hard gate in <code>BeginDestroy()</code> as the last line of defense. The tick queries themselves are gates too, each in its own place:</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="n">ETickableTickType</span> <span class="n">UTickableObject</span><span class="o">::</span><span class="n">GetTickableTickType</span><span class="p">()</span> <span class="k">const</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="c1">// Never for the CDO and before Initialize: the object stays out of the tickable
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>    <span class="c1">// array entirely instead of sitting in it and being polled every frame.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>    <span class="k">return</span> <span class="p">(</span><span class="n">IsTemplate</span><span class="p">()</span> <span class="o">||</span> <span class="o">!</span><span class="n">bInitialized</span><span class="p">)</span> <span class="o">?</span> <span class="n">ETickableTickType</span><span class="o">::</span><span class="nl">Never</span> <span class="p">:</span> <span class="n">ETickableTickType</span><span class="o">::</span><span class="n">Conditional</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kt">bool</span> <span class="n">UTickableObject</span><span class="o">::</span><span class="n">IsTickable</span><span class="p">()</span> <span class="k">const</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="k">return</span> <span class="n">bInitialized</span> <span class="o">&amp;&amp;</span> <span class="n">bTickEnabled</span> <span class="o">&amp;&amp;</span> <span class="n">CachedWorld</span><span class="p">.</span><span class="n">IsValid</span><span class="p">()</span> <span class="o">&amp;&amp;</span> <span class="n">IsValidChecked</span><span class="p">(</span><span class="k">this</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div></div>
<p>The split between these two methods is deliberate. <code>IsTemplate()</code> belongs in <code>GetTickableTickType</code>, not in <code>IsTickable</code>: that way the CDO never enters the array at all, instead of sitting in it and answering “no” every frame. <code>IsTickable</code> is left for the conditions that genuinely change over the object&rsquo;s lifetime.</p>
<div class="callout callout--note">
  <div class="callout__title">Note</div>
  <p>Implement <code>DisableTick()</code> as <code>SetTickableTickType(ETickableTickType::Never)</code>, a real removal from the array, rather than as a flag read in <code>IsTickable</code>. It comes at one cost worth remembering: re-enabling takes effect from the next tick pass, because <code>SetTickableTickType</code> adds the object to a pending queue (<code>Tickable.cpp:59-63</code>) that the engine drains at the start of the following pass (<code>Tickable.cpp:67-95</code>). An object enabled from inside <code>Tick()</code> does not tick a second time in the same frame.</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="c1">// UE 5.7 — Tickable.cpp:59-63, indentation reduced (branch for an object not yet in the array)
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="k">else</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="c1">// Add to the pending list (which could override previous request), this will apply it next frame
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>    <span class="n">NewTickableObjects</span><span class="p">.</span><span class="n">Add</span><span class="p">(</span><span class="n">InTickable</span><span class="p">,</span> <span class="n">NewTickType</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div></div>
</div>

<h2 id="decision-three-which-world-you-belong-to">Decision three: which world you belong to</h2>
<p>The default answer: <strong>none</strong>. Left unoverridden, <code>GetTickableGameObjectWorld()</code> returns <code>nullptr</code> (<code>Tickable.h:187-190</code>), and the object ticks in the global pass that follows all the worlds — knowing nothing about pause, nothing about PIE, nothing about the moment its world stops existing.</p>
<p>Overriding that method is cheap and handles all three at once:</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="n">UWorld</span><span class="o">*</span> <span class="n">UTickableObject</span><span class="o">::</span><span class="n">GetTickableGameObjectWorld</span><span class="p">()</span> <span class="k">const</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="k">return</span> <span class="n">CachedWorld</span><span class="p">.</span><span class="n">Get</span><span class="p">();</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div></div>
<p>I resolve the world once, in <code>Initialize()</code>, and hold it in a <code>TWeakObjectPtr&lt;UWorld&gt;</code>. Plain <code>GetWorld()</code> is enough: the default <code>UObject::GetWorld()</code> implementation walks the Outer chain (<code>Obj.cpp:1145-1150</code>), so an object created with a sensible Outer finds its world with no help at all.</p>
<p>Here is the trap I ran into. Once the world is gone, <code>CachedWorld.Get()</code> starts returning <code>nullptr</code>. You would expect that to be the end of the tick. The opposite is true. The gate in the engine reads <code>GetTickableGameObjectWorld() == World</code> (<code>Tickable.cpp:189</code>), and <code>TickObjects</code> is <strong>also</strong> called with <code>World == nullptr</code>, precisely for objects with no world (<code>GameEngine.cpp:1947</code>). The comparison <code>nullptr == nullptr</code> passes. The object does not stop ticking. It quietly <strong>migrates</strong> from its own world&rsquo;s tick to the global engine pass and keeps going.</p>
<p>The whole condition in the engine loop:</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="c1">// UE 5.7 — Tickable.cpp:186-189 (indentation reduced)
</span></span></span><span class="line"><span class="cl"><span class="c1">// If it is tickable and in this world
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="k">if</span> <span class="p">(</span><span class="n">TickableObject</span><span class="o">-&gt;</span><span class="n">IsAllowedToTick</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">    <span class="o">&amp;&amp;</span> <span class="p">((</span><span class="n">TickableEntry</span><span class="p">.</span><span class="n">TickType</span> <span class="o">==</span> <span class="n">ETickableTickType</span><span class="o">::</span><span class="n">Always</span><span class="p">)</span> <span class="o">||</span> <span class="n">TickableObject</span><span class="o">-&gt;</span><span class="n">IsTickable</span><span class="p">())</span>
</span></span><span class="line"><span class="cl">    <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="n">TickableObject</span><span class="o">-&gt;</span><span class="n">GetTickableGameObjectWorld</span><span class="p">()</span> <span class="o">==</span> <span class="n">World</span><span class="p">))</span></span></span></code></pre></div></div>
<p>Closing this takes two things at once: the <code>CachedWorld.IsValid()</code> condition in <code>IsTickable()</code>, and a subscription to world cleanup, so that the object shuts itself down instead of just no longer being polled.</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="kt">void</span> <span class="n">UTickableObject</span><span class="o">::</span><span class="n">HandleWorldCleanup</span><span class="p">(</span><span class="n">UWorld</span><span class="o">*</span> <span class="n">World</span><span class="p">,</span> <span class="kt">bool</span> <span class="n">bSessionEnded</span><span class="p">,</span> <span class="kt">bool</span> <span class="n">bCleanupResources</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="k">if</span> <span class="p">(</span><span class="n">World</span> <span class="o">==</span> <span class="n">CachedWorld</span><span class="p">.</span><span class="n">Get</span><span class="p">())</span>
</span></span><span class="line"><span class="cl">    <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="n">Shutdown</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div></div>
<p>The delegate is <code>FWorldDelegates::OnWorldCleanup</code>, hooked up in <code>Initialize()</code> and removed in <code>Shutdown()</code>. Unregistering from inside your own broadcast is safe: Unreal&rsquo;s multicast delegates defer compacting the list until the call finishes (<code>MulticastDelegateBase.h:380-390</code>).</p>
<h2 id="decision-four-who-cleans-up">Decision four: who cleans up</h2>
<p>The default answer: <strong>nobody</strong>. A <code>UObject</code> with no <code>UPROPERTY</code> reference is collected at the next GC, and that is the correct behavior. It just has to be handled deliberately, instead of discovered halfway through a session when the object is already gone.</p>
<p>The reflex is <code>AddToRoot()</code>. That is not lifetime management; it is turning GC off for this object, with a manual <code>RemoveFromRoot()</code> as the only way out. The object survives a map change and everything else.</p>
<p>A sensible contract is simpler and puts both obligations on the owner: the object lives in a <code>UPROPERTY(TObjectPtr&lt;&gt;)</code>, and <code>Shutdown()</code> runs before that reference is dropped.</p>
<div class="callout callout--warning">
  <div class="callout__title">Warning</div>
  <p><strong>Teardown does not belong in <code>BeginDestroy()</code>.</strong> It is tempting to hook it there — it looks like a fair way to close the lifecycle, one that saves a forgetful owner. It blows up Blueprint subclasses.</p>
<p>On the GC path the object already has the <code>Unreachable</code> flag set (<code>GarbageCollection.cpp:5264</code>, before <code>ConditionalBeginDestroy</code> is even called in <code>GarbageCollection.cpp:6155</code>), and a <code>BlueprintNativeEvent</code> overridden in Blueprint dispatches through <code>UObject::ProcessEvent</code>, which opens with <code>checkf(!IsUnreachable(), ...)</code> (<code>ScriptCore.cpp:2015-2020</code>).</p>
<p>The result: the first Blueprint subclass to implement the teardown event crashes the editor during an ordinary garbage collection. In a Shipping build the <code>check</code> is gone, so instead of a crash you get a silently skipped teardown — behavior that differs by build configuration, which is harder still to catch.</p>

</div>

<p>So <code>BeginDestroy()</code> does exactly as much as it has to and not an ounce more: it removes the delegate (a plain <code>Remove</code>, no dispatch into Blueprint), kills the tick, and reports that the owner never called <code>Shutdown()</code>.</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="kt">void</span> <span class="n">UTickableObject</span><span class="o">::</span><span class="n">BeginDestroy</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">FWorldDelegates</span><span class="o">::</span><span class="n">OnWorldCleanup</span><span class="p">.</span><span class="n">Remove</span><span class="p">(</span><span class="n">WorldCleanupHandle</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">    <span class="n">WorldCleanupHandle</span><span class="p">.</span><span class="n">Reset</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">    <span class="n">SetTickableTickType</span><span class="p">(</span><span class="n">ETickableTickType</span><span class="o">::</span><span class="n">Never</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">    <span class="n">bTickEnabled</span> <span class="o">=</span> <span class="nb">false</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">    <span class="n">ensureAlwaysMsgf</span><span class="p">(</span><span class="o">!</span><span class="n">bInitialized</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">        <span class="n">TEXT</span><span class="p">(</span><span class="s">&#34;%s: destroyed while still initialized - the owner never called Shutdown().&#34;</span><span class="p">),</span> <span class="o">*</span><span class="n">GetName</span><span class="p">());</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">    <span class="n">Super</span><span class="o">::</span><span class="n">BeginDestroy</span><span class="p">();</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div></div>
<p><code>ensureAlwaysMsgf</code>, not <code>ensureMsgf</code>: a plain <code>ensure</code> fires once per callsite per process. The <code>bEnsureHasExecuted</code> flag is keyed by a hash of <code>__FILE__</code> and <code>__LINE__</code>, and the <code>Always</code> variant skips that filter (<code>AssertionMacros.h:440-448</code>). The first leaked object would silence the diagnostic for every one after it.</p>
<p>Epic does the same in <code>UTickableWorldSubsystem::BeginDestroy</code> (<code>WorldSubsystem.cpp:154-159</code>): it does not call <code>Deinitialize</code> from there — and now the reason is clear. Two differences from the listing above are deliberate: Epic leaves a plain <code>ensureMsgf</code> there (<code>WorldSubsystem.cpp:158</code>) and calls <code>Super::BeginDestroy()</code> first (<code>WorldSubsystem.cpp:156</code>).</p>
<h2 id="the-whole-class">The whole class</h2>
<p>The complete implementation ships in <a href="/en/products/stillcooking-tools/">StillCooking_Tools</a> as
<code>USCTickableObject</code> — a free, MIT-licensed plugin distributed as C++ source
(<a href="https://github.com/StillCooking/StillCooking_Tools" data-external rel="noopener" target="_blank">GitHub</a>), module <code>StillCookingCore</code>, header
<code>Objects/SCTickableObject.h</code>. It is the class from this post, developed further: on top of the four
decisions above it adds an explicit tick intent that <code>Initialize()</code> applies, the <code>bTickWhenPaused</code>
and <code>bTickInEditor</code> gates, and a <code>protected</code> engine-facing interface with <code>IsTickable()</code> marked
<code>final</code>.</p>
<ul>
<li><a href="/en/products/stillcooking-tools/docs/reference/tickable-object/">Reference: <code>USCTickableObject</code></a> —
functions, properties, events and the messages it logs.</li>
<li><a href="/en/products/stillcooking-tools/docs/concepts/lifecycle/">Lifecycle</a> — the ownership contract and
what happens when the owner forgets <code>Shutdown()</code>.</li>
</ul>
<h2 id="checklist">Checklist</h2>
<p>Five things to check in your own class:</p>
<ol>
<li>The constructor calls <code>FTickableGameObject(ETickableTickType::Never)</code> and does <strong>nothing else</strong> tick-related.</li>
<li><code>GetTickableTickType()</code> returns <code>Never</code> for <code>IsTemplate()</code> and for the pre-initialization state, so the CDO never enters the array.</li>
<li><code>GetTickableGameObjectWorld()</code> returns a real world, and <code>IsTickable()</code> checks whether that world is still alive.</li>
<li>There is an explicit shutdown method called by the owner, plus a world-cleanup subscription for the case where the world goes first.</li>
<li><code>BeginDestroy()</code> kills the tick and reports the problem, but does <strong>not</strong> run subclass teardown.</li>
</ol>
]]></content:encoded>
      
    </item>
    
    <item>
      <title>Subsystem and manager actor lifecycles — who, when, and in what order</title>
      <link>https://stillcooking.dev/en/topics/unreal-engine/gameplay-framework/subsystem-lifecycle-init-order/</link>
      <pubDate>Tue, 21 Jul 2026 00:00:00 +0000</pubDate>
      
      <guid isPermaLink="true">https://stillcooking.dev/en/topics/unreal-engine/gameplay-framework/subsystem-lifecycle-init-order/</guid>
      <description>Five subsystem base classes, each with a different owner. Where the engine creates and tears down each collection, how world startup relates to actor BeginPlay, and where initialization order is no longer guaranteed.</description>
      <content:encoded><![CDATA[<h2 id="five-collections-five-owners">Five collections, five owners</h2>
<p>A subsystem derives from one of five base classes. Each subsystem type is associated with a different owner and inherits that owner’s lifetime: <code>UEngineSubsystem</code>, <code>UEditorSubsystem</code>, <code>UGameInstanceSubsystem</code>, <code>UWorldSubsystem</code> (plus <code>UTickableWorldSubsystem</code>), or <code>ULocalPlayerSubsystem</code> (<code>Runtime/Engine/Public/Subsystems/Subsystem.h:12-20</code>). Everything below comes from reading the UE 5.8 source.</p>
<p>Choosing the base class is how you declare the subsystem&rsquo;s lifetime. Everything else happens automatically.</p>
<p>All five follow the same contract: <code>ShouldCreateSubsystem(UObject* Outer)</code> → <code>Initialize</code> → <code>Deinitialize</code>. The first call is the exception. It runs on the CDO before an instance even exists, as the header states explicitly: <em>&ldquo;Note: This function is called on the CDO prior to instances being created!&rdquo;</em> (<code>Subsystem.h:49-56</code>).</p>
<p>Under the hood, the collection gathers every non-abstract derived class through <code>GetDerivedClasses(BaseType, …, true)</code> and asks each CDO whether that subsystem should be created (<code>Private/Subsystems/SubsystemCollection.cpp:256,373-391</code>). It stores the resulting instances in a <code>TMap&lt;UClass*, USubsystem*&gt;</code> (<code>Public/Subsystems/SubsystemCollection.h:116-143</code>). One instance per class per Outer isn’t a convention; it follows from the container type. The key is a concrete class, not a hierarchy. If another non-abstract class derives from that base class — a Blueprint child, for instance — its CDO gets asked the same question separately, and the collection ends up holding two independent instances. How this affects which class provides the implementation is covered separately in <a href="/en/topics/unreal-engine/gameplay-framework/should-create-subsystem-picks-the-class">ShouldCreateSubsystem and the subsystem class hierarchy</a>.</p>
<h2 id="where-each-collection-starts">Where each collection starts</h2>
<div class="table-wrap">
  <table>
    <thead>
      <tr>
        <th>Collection</th>
        <th>Created</th>
        <th>Torn down</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Engine (dynamic)</td>
        <td>collection: <code>UEngine::Init</code> — <code>Private/UnrealEngine.cpp:2403</code>; instances: module load — <code>Subsystem.h:72-83</code></td>
        <td><code>UEngine::PreExit</code> — <code>:2757</code>; instances: module unload</td>
      </tr>
      <tr>
        <td>Editor (dynamic)</td>
        <td>instances: module load — <code>Editor/EditorSubsystem/Public/EditorSubsystem.h:9-23</code></td>
        <td>module unload</td>
      </tr>
      <tr>
        <td>GameInstance</td>
        <td><code>UGameInstance::Init</code> — <code>Private/GameInstance.cpp:129</code></td>
        <td><code>UGameInstance::Shutdown</code> — <code>:167</code></td>
      </tr>
      <tr>
        <td>World</td>
        <td><code>UWorld::InitWorld</code> — <code>Private/World.cpp:2414</code></td>
        <td><code>UWorld::CleanupWorldInternal</code> — <code>:6476,6486</code></td>
      </tr>
      <tr>
        <td>LocalPlayer</td>
        <td><code>ULocalPlayer::PlayerAdded</code> — <code>Private/LocalPlayer.cpp:262,270</code></td>
        <td><code>ULocalPlayer::PlayerRemoved</code> — <code>:280</code></td>
      </tr>
    </tbody>
  </table>
</div>
<p>The first two rows are the easiest to get wrong. <code>UEditorSubsystem</code> and <code>UEngineSubsystem</code> derive from <code>UDynamicSubsystem</code>, which automatically populates the collection when a module loads and empties it when that module unloads. Your subsystem won’t exist until its module is explicitly loaded, and the engine won’t report an error if it isn’t.</p>
<div class="callout callout--warning">
  <div class="callout__title">Warning</div>
  The trap in the LocalPlayer row is hidden in the owner’s name. The collection doesn’t start when the <code>ULocalPlayer</code> object is created. It starts in <code>PlayerAdded</code>, after the player has been attached to a <code>UGameViewportClient</code>. Both overloads of that method call <code>SubsystemCollection.Initialize(this)</code> (<code>Private/LocalPlayer.cpp:257-271</code>), while <code>PlayerRemoved</code> deinitializes the collection (<code>:278-280</code>).
</div>

<div class="callout callout--insight">
  <div class="callout__title">Insight</div>
  In PIE, every client instance gets its own <code>UGameInstance</code>. This means the GameInstance, World, and LocalPlayer subsystems are created and destroyed with the PIE session, while Engine and Editor subsystems survive across many sessions in the same editor process. That difference is the most common source of state leaking between PIE runs.
</div>

<h2 id="the-world-startup-timeline">The world startup timeline</h2>
<p>By the time this timeline begins, the Engine and GameInstance collections have already been initialized. <code>UEngine::Init</code> runs during process startup, and <code>UGameInstance::Init</code> runs before the map load that creates the gameplay world.</p>
<div class="callout callout--note">
  <div class="callout__title">Note</div>
  One exception breaks this intuition: <code>UGameInstance::InitializeStandalone</code> creates a dummy world before calling its own <code>Init()</code> (<code>Private/GameInstance.cpp:190-202</code>). The World subsystems for that dummy world are therefore initialized before the GameInstance subsystems. The dummy world is destroyed during the first <code>LoadMap</code>.
</div>

<p>The relevant points in the timeline are all in <code>Runtime/Engine/Private/World.cpp</code>:</p>
<ol>
<li><strong><code>UWorld::InitWorld()</code></strong> calls <code>InitializeSubsystems</code> (<code>:2447</code>) and, near the end, <code>PostInitializeSubsystems</code> (<code>:2610</code>). World subsystems receive both <code>Initialize</code> and <code>PostInitialize</code>.</li>
<li><strong><code>UWorld::InitializeActorsForPlay()</code></strong> runs (<code>:5946</code>). Only then does the engine start handling actors placed in the level.</li>
<li><strong><code>UWorld::BeginPlay()</code></strong> calls <code>OnWorldBeginPlay</code> on every World subsystem and <strong>then</strong> calls <code>AGameModeBase::StartPlay()</code> (<code>:6165-6179</code>).</li>
</ol>
<p>The third point gives us a guarantee that no actor can provide: a World subsystem has been initialized and has already run <code>OnWorldBeginPlay</code> before GameMode starts gameplay. An actor placed in the level receives its <code>BeginPlay</code> during <code>InitializeActorsForPlay</code>/<code>StartPlay</code>, which puts it after the subsystems. That last part is my interpretation of the call order, not a guarantee stated on any single line of engine code, but it follows directly from that order.</p>
<p>An actor spawned during play is a different case. Its <code>BeginPlay</code> fires immediately after it is spawned, so the startup-order question doesn’t apply.</p>
<p>A manager actor comes close to providing the same guarantee, but only when three conditions are met: it derives from <code>AInfo</code> (or explicitly sets <code>bIsSpatiallyLoaded = false</code>), lives in the persistent level, and has no dependency on a streamed sublevel. The <code>AInfo</code> constructor sets <code>bIsSpatiallyLoaded = false</code> and <code>bReplicates = false</code> (<code>Private/Info.cpp:11-45</code>), which is exactly the kind of role Epic designed this class for.</p>
<p>A plain <code>AActor</code> placed in a World Partition level is spatially streamed by default and can be unloaded during gameplay. A subsystem is structurally immune to this class of bug because it doesn’t belong to any <code>ULevel</code>.</p>
<h2 id="where-the-ordering-guarantee-stops">Where the ordering guarantee stops</h2>
<p>The guarantee from the previous section applies only to this ordering. Everything below falls outside it, and that is where the assumption that “the subsystem is always there” breaks down.</p>
<p><strong>There is no declarative ordering between collections.</strong> <code>FSubsystemCollectionBase::InitializeDependency</code> enforces ordering within a single collection and nowhere else. The header states this plainly: <em>&ldquo;Dependencies only work within a collection&rdquo;</em> (<code>Public/Subsystems/SubsystemCollection.h:31-45</code>). A World subsystem that accesses a GameInstance subsystem from inside <code>Initialize</code> has no declarative safeguard. You must either enforce the order yourself or defer that access until <code>OnWorldBeginPlay</code>, when the world has already been assembled.</p>
<p><strong>A dynamic subsystem whose module hasn’t loaded never appears.</strong> A <code>UEditorSubsystem</code> placed in a module with the wrong <code>LoadingPhase</code> simply never reaches the collection (<code>Subsystem.h:72-83</code>, <code>EditorSubsystem.h:9-23</code>). The symptom is misleading: <code>GetEditorSubsystem&lt;T&gt;()</code> returns null even though the class compiles, loads, and looks perfectly fine in the editor.</p>
<p><strong>A class that hasn&rsquo;t been loaded never even makes the list.</strong> This is the same mechanism as the point above, seen from the other side. Non-dynamic collections run their <code>GetDerivedClasses</code> scan once, when the collection is created, and they only see the classes that are in memory at that moment. A Blueprint child of a subsystem with no hard references to that child isn&rsquo;t loaded yet in a packaged build, so its CDO is never asked — and at the default log level a refusal and an absence look identical: both are just a missing line. The editor never shows the problem, because the Content Browser keeps the class in memory. I covered the whole case in <a href="/en/topics/unreal-engine/gameplay-framework/blueprint-subsystem-missing-in-packaged-build">A Blueprint subsystem does not get created in a packaged build</a>.</p>
<p><strong>A conditional <code>ShouldCreateSubsystem</code> eliminates the non-null guarantee.</strong> Epic does this in its own code: <code>UInputDeviceSubsystem</code> returns <code>false</code> on a dedicated server, in a commandlet, and when Slate hasn’t been initialized (<code>Private/GameFramework/InputDeviceSubsystem.cpp:240-252</code>). The consequence is visible in the subsystem’s own accessor. <code>UInputDeviceSubsystem::Get()</code> returns <code>nullptr</code> (<code>:194-197</code>), so every call within the engine is wrapped in an <code>if</code>, three times in <code>ForceFeedbackEffect.cpp</code> alone (<code>:122</code>, <code>:190</code>, <code>:214</code>).</p>
<p>Overriding this hook gives up the very property that often makes a subsystem appealing in the first place. From that point on, every <code>GetSubsystem&lt;T&gt;()</code> requires a null check, and the call site has no way to know whether it is running on a path where the subsystem was created. Sometimes that tradeoff is intentional. The condition in this method doubles as a way of declaring which class in the hierarchy should be the subsystem, and the null check becomes the price of moving the implementation one level down, <a href="/en/topics/unreal-engine/gameplay-framework/should-create-subsystem-picks-the-class">into a Blueprint</a>.</p>
<p><strong><code>DoesSupportWorldType</code> includes editor worlds by default.</strong> A gameplay manager that doesn’t override this method gets an instance in every world opened in the editor, not just in PIE. This happens because <code>UWorldSubsystem</code> overrides <code>ShouldCreateSubsystem</code> through <code>DoesSupportWorldType</code>, whose default implementation allows game, PIE, <strong>and</strong> editor worlds (<code>Public/Subsystems/WorldSubsystem.h:33-66</code>, especially <code>:64-66</code>). If the subsystem also derives from <code>UTickableWorldSubsystem</code>, it ticks from <code>Initialize</code> to <code>Deinitialize</code> for as long as the map remains open in the editor (<code>WorldSubsystem.h:72-106</code>).</p>
<h2 id="confirming-this-in-your-own-project">Confirming this in your own project</h2>
<p>You can verify the entire timeline above in a single editor run. Log four points and include the world type on every line:</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="kt">void</span> <span class="n">UMyWorldSubsystem</span><span class="o">::</span><span class="n">Initialize</span><span class="p">(</span><span class="n">FSubsystemCollectionBase</span><span class="o">&amp;</span> <span class="n">Collection</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">Super</span><span class="o">::</span><span class="n">Initialize</span><span class="p">(</span><span class="n">Collection</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">    <span class="n">UE_LOG</span><span class="p">(</span><span class="n">LogMyGame</span><span class="p">,</span> <span class="n">Log</span><span class="p">,</span> <span class="n">TEXT</span><span class="p">(</span><span class="s">&#34;[1] Subsystem::Initialize | World=%s Type=%d&#34;</span><span class="p">),</span>
</span></span><span class="line"><span class="cl">        <span class="o">*</span><span class="n">GetWorld</span><span class="p">()</span><span class="o">-&gt;</span><span class="n">GetName</span><span class="p">(),</span> <span class="p">(</span><span class="n">int32</span><span class="p">)</span><span class="n">GetWorld</span><span class="p">()</span><span class="o">-&gt;</span><span class="n">WorldType</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kt">void</span> <span class="n">UMyWorldSubsystem</span><span class="o">::</span><span class="n">OnWorldBeginPlay</span><span class="p">(</span><span class="n">UWorld</span><span class="o">&amp;</span> <span class="n">InWorld</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">Super</span><span class="o">::</span><span class="n">OnWorldBeginPlay</span><span class="p">(</span><span class="n">InWorld</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">    <span class="n">UE_LOG</span><span class="p">(</span><span class="n">LogMyGame</span><span class="p">,</span> <span class="n">Log</span><span class="p">,</span> <span class="n">TEXT</span><span class="p">(</span><span class="s">&#34;[2] Subsystem::OnWorldBeginPlay&#34;</span><span class="p">));</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1">// AMyManagerActor::BeginPlay  → [3]
</span></span></span><span class="line"><span class="cl"><span class="c1">// AMyGameMode::StartPlay      → [4]
</span></span></span></code></pre></div></div>
<p>Seeing <code>1 → 2 → 3 → 4</code> in the log confirms the guarantee for one specific project and one specific streaming setup. If <code>[3]</code> appears before <code>[2]</code>, the actor is being spawned rather than placed in the level. Its <code>BeginPlay</code> fires immediately after the spawn and has nothing to do with the world startup timeline.</p>
<div class="section-panel section-panel--checklist">
  <div class="section-panel__label">Checklist</div>
  
<p>Additional checks, each answering a different question:</p>
<ul class="checklist">
  <li><strong>Who created me, and from where?</strong> — set a breakpoint on <code>FSubsystemCollectionBase::AddAndInitializeSubsystem</code>. The call stack shows both the collection and the point in the engine that created it (<code>UEngine::Init</code>, <code>UGameInstance::Init</code>, <code>UWorld::InitWorld</code>, or a module load).</li>
  <li><strong>Am I cluttering up the editor?</strong> — if line <code>[1]</code> appears when you simply open a map without starting PIE, then <code>DoesSupportWorldType</code> hasn’t been overridden. Filtering for <code>WorldType == EWorldType::Game || WorldType == EWorldType::PIE</code> fixes it.</li>
  <li><strong>Does my manager actor really survive?</strong> — check the actor’s <code>bIsSpatiallyLoaded</code> value in the Details panel under World Partition, and confirm that it belongs to the persistent level. Both conditions must be satisfied.</li>
  <li><strong>Was my class asked at all?</strong> — run with <code>-LogCmds="LogSubsystemCollection VeryVerbose"</code>. A <code>CDO choose to not create</code> line means the class was on the list and refused; the absence of that line alongside a missing instance means nobody ever asked it. In that second case the breakpoint from the first check never fires, so on its own it settles nothing.</li>
</ul>

</div>

<p>The ordering guarantee is real, and the engine code enforces it, but it covers exactly one thing: a World subsystem exists before actors in that same world receive <code>BeginPlay</code>. It extends no further than that single axis. Everything above also covers startup only; the order in which a world and a session shut down is a separate question, and this note leaves it open.</p>
<p>The game code has to answer every other question for itself, and the engine won’t even signal that the question came up.</p>
]]></content:encoded>
      
    </item>
    
    <item>
      <title>Casting to an interface misses Blueprint implementations</title>
      <link>https://stillcooking.dev/en/topics/unreal-engine/cpp-in-unreal/interface-cast-misses-blueprint/</link>
      <pubDate>Tue, 07 Jul 2026 00:00:00 +0000</pubDate>
      
      <guid isPermaLink="true">https://stillcooking.dev/en/topics/unreal-engine/cpp-in-unreal/interface-cast-misses-blueprint/</guid>
      <description>Cast&lt;IMyInterface&gt;(Obj) returns nullptr when an object&amp;rsquo;s interface implementation exists only in Blueprint, even though ImplementsInterface() returns true for that same object. The engine skips entries marked bImplementedByK2, so casting to an interface is safe only when that interface is explicitly blocked from Blueprint implementation.</description>
      <content:encoded><![CDATA[<h2 id="two-ways-to-call">Two ways to call</h2>
<p>There are two ways to call an interface function in Unreal: cast to the <code>I*</code> type or use the generated <code>Execute_</code> wrapper. They look interchangeable, but they ask the engine two different questions.</p>
<p><code>Cast&lt;IMyInterface&gt;(Obj)</code> returns <code>nullptr</code> for an object whose interface implementation exists only in Blueprint. For that same object, <code>Obj-&gt;GetClass()-&gt;ImplementsInterface(UMyInterface::StaticClass())</code> returns <code>true</code>. The engine deliberately skips interface entries added by the Blueprint compiler, so casting to <code>I*</code> is safe only when the interface is explicitly marked as non-implementable in Blueprint. Everywhere else, it is a silent bug waiting for the day a designer creates a Blueprint implementation.</p>
<p>The whole problem comes down to one specific configuration: a native interface declared in C++ and implemented in Blueprint.</p>
<h2 id="two-functions-one-condition-apart">Two functions, one condition apart</h2>
<p><code>GetInterfaceAddress</code> and <code>ImplementsInterface</code> both walk the same <code>UClass::Interfaces</code> array and test the same relationship with <code>IsChildOf</code>. Exactly one extra condition separates them.</p>
<p><code>UObjectBaseUtility::GetInterfaceAddress</code> (<code>Engine/Source/Runtime/CoreUObject/Private/UObject/UObjectBaseUtility.cpp</code>), in the branch for a native interface:</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="k">for</span> <span class="p">(</span><span class="n">TArray</span><span class="o">&lt;</span><span class="n">FImplementedInterface</span><span class="o">&gt;::</span><span class="n">TIterator</span> <span class="n">It</span><span class="p">(</span><span class="n">CurrentClass</span><span class="o">-&gt;</span><span class="n">Interfaces</span><span class="p">);</span> <span class="n">It</span><span class="p">;</span> <span class="o">++</span><span class="n">It</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="c1">// See if this is the implementation we are looking for, and it was done natively, not in K2
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>    <span class="n">FImplementedInterface</span><span class="o">&amp;</span> <span class="n">ImplInterface</span> <span class="o">=</span> <span class="o">*</span><span class="n">It</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="k">if</span> <span class="p">(</span> <span class="o">!</span><span class="n">ImplInterface</span><span class="p">.</span><span class="n">bImplementedByK2</span> <span class="o">&amp;&amp;</span> <span class="n">ImplInterface</span><span class="p">.</span><span class="n">Class</span><span class="o">-&gt;</span><span class="n">IsChildOf</span><span class="p">(</span><span class="n">InterfaceClass</span><span class="p">)</span> <span class="p">)</span>
</span></span><span class="line"><span class="cl">    <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="n">Result</span> <span class="o">=</span> <span class="p">(</span><span class="n">uint8</span><span class="o">*</span><span class="p">)</span><span class="k">this</span> <span class="o">+</span> <span class="n">It</span><span class="o">-&gt;</span><span class="n">PointerOffset</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">        <span class="k">break</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div></div>
<p><code>UClass::ImplementsInterface</code> (<code>Engine/Source/Runtime/CoreUObject/Private/UObject/Class.cpp</code>), with the same loop:</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="k">for</span> <span class="p">(</span><span class="n">TArray</span><span class="o">&lt;</span><span class="n">FImplementedInterface</span><span class="o">&gt;::</span><span class="n">TConstIterator</span> <span class="n">It</span><span class="p">(</span><span class="n">CurrentClass</span><span class="o">-&gt;</span><span class="n">Interfaces</span><span class="p">);</span> <span class="n">It</span><span class="p">;</span> <span class="o">++</span><span class="n">It</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="k">const</span> <span class="n">UClass</span><span class="o">*</span> <span class="n">InterfaceClass</span> <span class="o">=</span> <span class="n">It</span><span class="o">-&gt;</span><span class="n">Class</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="k">if</span> <span class="p">(</span><span class="n">InterfaceClass</span> <span class="o">&amp;&amp;</span> <span class="n">InterfaceClass</span><span class="o">-&gt;</span><span class="n">IsChildOf</span><span class="p">(</span><span class="n">SomeInterface</span><span class="p">))</span>
</span></span><span class="line"><span class="cl">    <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="k">return</span> <span class="nb">true</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div></div>
<p>The entire difference is <code>!ImplInterface.bImplementedByK2</code>. That flag marks an entry produced by the Blueprint compiler, and the engine&rsquo;s own comment says exactly that: <em>&ldquo;and it was done natively, not in K2.&rdquo;</em> <code>ImplementsInterface</code> has no such filter, so it gives the broader answer: the class implements the interface. <code>GetInterfaceAddress</code> gives a narrower answer: the class implements the interface <strong>natively</strong>.</p>
<div class="callout callout--insight">
  <div class="callout__title">Insight</div>
  <code>ImplementsInterface</code> asks whether the class implements the interface. <code>GetInterfaceAddress</code>, the function behind <code>Cast&lt;I*&gt;</code>, asks a narrower question: whether the class implements it <strong>natively</strong>. For a class whose interface implementation exists only in Blueprint, the first returns <code>true</code>, while the second returns <code>nullptr</code>.
</div>

<p>And <code>GetInterfaceAddress</code> is the cast. Not figuratively but literally, in <code>Engine/Source/Runtime/CoreUObject/Public/Templates/Casts.h</code>:</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="k">if</span> <span class="nf">constexpr</span> <span class="p">(</span><span class="n">TIsIInterface</span><span class="o">&lt;</span><span class="n">To</span><span class="o">&gt;::</span><span class="n">Value</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="k">return</span> <span class="p">(</span><span class="n">To</span><span class="o">*</span><span class="p">)((</span><span class="n">UObject</span><span class="o">*</span><span class="p">)</span><span class="n">Src</span><span class="p">)</span><span class="o">-&gt;</span><span class="n">GetInterfaceAddress</span><span class="p">(</span><span class="n">To</span><span class="o">::</span><span class="n">UClassType</span><span class="o">::</span><span class="n">StaticClass</span><span class="p">());</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div></div>
<p>A cast to an interface never touches the class-cast-flag path used by a plain <code>Cast&lt;AActor&gt;</code>. Instead, it calls a function designed specifically to exclude Blueprint implementations.</p>
<h2 id="why-there-is-nothing-to-return">Why there is nothing to return</h2>
<p>This looks like an oversight. It is a constraint of the memory layout.</p>
<p>A C++ class that implements <code>IMyInterface</code> inherits from it, so its memory layout contains an <code>IMyInterface</code> subobject at a known offset. That offset is exactly what the cast is built on: <code>(uint8*)this + It-&gt;PointerOffset</code>. If the interface is implemented only in Blueprint, there is no corresponding native <code>IMyInterface</code> subobject, so there is nothing for <code>PointerOffset</code> to describe. Without that subobject, there is no <code>IMyInterface</code> vtable either, and therefore no address for the cast to return.</p>
<p>A Blueprint implementation exists in a completely different form. It is a <code>UFunction</code> on the Blueprint class, invoked through the virtual machine. No valid pointer exists, so <code>nullptr</code> is the only honest answer.</p>
<p><code>Cast</code> itself is what makes this misleading: it looks like a uniform reflection mechanism, but in this case it is really asking about native memory layout.</p>
<h2 id="the-fix-execute_">The fix: <code>Execute_</code></h2>
<p>For every interface function, UHT generates a static <code>Execute_Foo</code> wrapper. <code>AppendInterfaceCallFunction</code> (<code>Engine/Source/Programs/Shared/EpicGames.UHT/Exporters/CodeGen/UhtHeaderCodeGeneratorCppFile.cs</code>) emits the body, which expands to this:</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="k">static</span> <span class="n">FName</span> <span class="n">NAME_UMyInterface_Foo</span> <span class="o">=</span> <span class="n">FName</span><span class="p">(</span><span class="n">TEXT</span><span class="p">(</span><span class="s">&#34;Foo&#34;</span><span class="p">));</span>
</span></span><span class="line"><span class="cl"><span class="kt">void</span> <span class="n">IMyInterface</span><span class="o">::</span><span class="n">Execute_Foo</span><span class="p">(</span><span class="n">UObject</span><span class="o">*</span> <span class="n">O</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">check</span><span class="p">(</span><span class="n">O</span> <span class="o">!=</span> <span class="nb">NULL</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">    <span class="n">check</span><span class="p">(</span><span class="n">O</span><span class="o">-&gt;</span><span class="n">GetClass</span><span class="p">()</span><span class="o">-&gt;</span><span class="n">ImplementsInterface</span><span class="p">(</span><span class="n">UMyInterface</span><span class="o">::</span><span class="n">StaticClass</span><span class="p">()));</span>
</span></span><span class="line"><span class="cl">    <span class="n">UFunction</span><span class="o">*</span> <span class="k">const</span> <span class="n">Func</span> <span class="o">=</span> <span class="n">O</span><span class="o">-&gt;</span><span class="n">FindFunction</span><span class="p">(</span><span class="n">NAME_UMyInterface_Foo</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">    <span class="k">if</span> <span class="p">(</span><span class="n">Func</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">    <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="n">O</span><span class="o">-&gt;</span><span class="n">ProcessEvent</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl">    <span class="k">else</span> <span class="nf">if</span> <span class="p">(</span><span class="k">auto</span> <span class="n">I</span> <span class="o">=</span> <span class="p">(</span><span class="n">IMyInterface</span><span class="o">*</span><span class="p">)(</span><span class="n">O</span><span class="o">-&gt;</span><span class="n">GetNativeInterfaceAddress</span><span class="p">(</span><span class="n">UMyInterface</span><span class="o">::</span><span class="n">StaticClass</span><span class="p">())))</span>
</span></span><span class="line"><span class="cl">    <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="n">I</span><span class="o">-&gt;</span><span class="n">Foo_Implementation</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div></div>
<p>The order is the opposite of what you would expect. <code>FindFunction</code> comes first. That is the reflection path, and it finds a Blueprint override just as well as a UHT-registered native function. Only when there is no <code>UFunction</code> does the wrapper retrieve the native subobject address and call <code>_Implementation</code> directly.</p>
<p><code>Execute_</code> gates itself on <code>ImplementsInterface</code>, the broader check, not on the existence of an interface address.</p>
<p>The correct call site therefore looks like this:</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="k">if</span> <span class="p">(</span><span class="n">Obj</span><span class="o">-&gt;</span><span class="n">Implements</span><span class="o">&lt;</span><span class="n">UMyInterface</span><span class="o">&gt;</span><span class="p">())</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">IMyInterface</span><span class="o">::</span><span class="n">Execute_Foo</span><span class="p">(</span><span class="n">Obj</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div></div>
<p>A second safeguard sits in the native body of the event function itself. For interfaces, UHT emits that body as a hard assertion:</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="n">check</span><span class="p">(</span><span class="mi">0</span> <span class="o">&amp;&amp;</span> <span class="s">&#34;Do not directly call Event functions in Interfaces. Call Execute_Foo instead.&#34;</span><span class="p">);</span></span></span></code></pre></div></div>
<p>That gives <code>Cast&lt;IMyInterface&gt;(Obj)-&gt;Foo()</code> two independent ways to fail. Either the cast returns <code>nullptr</code> and the program crashes on the dereference, or the cast succeeds and the call runs straight into the assertion. The <code>nullptr</code> failure is worse because it occurs only for objects whose interface implementation comes from Blueprint.</p>
<h2 id="when-the-cast-is-valid">When the cast is valid</h2>
<p>A cast to <code>I*</code> covers every implementation of the interface under exactly one condition: the interface must be explicitly non-implementable in Blueprint. Then <code>bImplementedByK2</code> is never set on any entry, so <code>GetInterfaceAddress</code> and <code>ImplementsInterface</code> always agree.</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="n">UINTERFACE</span><span class="p">(</span><span class="n">BlueprintType</span><span class="p">,</span> <span class="n">meta</span><span class="o">=</span><span class="p">(</span><span class="n">CannotImplementInterfaceInBlueprint</span><span class="p">),</span> <span class="n">MinimalAPI</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="k">class</span> <span class="nc">UDamageSource</span> <span class="o">:</span> <span class="k">public</span> <span class="n">UInterface</span> <span class="p">{</span> <span class="n">GENERATED_BODY</span><span class="p">()</span> <span class="p">};</span></span></span></code></pre></div></div>
<div class="callout callout--tip">
  <div class="callout__title">Tip</div>
  This leads to the rule I follow: casting to <code>I*</code> is allowed only when I declare the interface myself and explicitly prevent it from being implemented in Blueprint. Everywhere else, use <code>Implements&lt;&gt;</code> plus <code>Execute_</code>.
</div>

<h2 id="verification">Verification</h2>
<p>I verified this in the editor, not just by reading the source. The probe collects three readings for the same object: <code>ImplementsInterface</code>, a cast to the interface type, and <code>GetNativeInterfaceAddress</code>. It then calls <code>Execute_</code>. The test interface allows Blueprint implementations, so the test can cover the case where the cast fails:</p>
<div class="highlight" data-lang="cpp">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="n">UINTERFACE</span><span class="p">(</span><span class="n">Blueprintable</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="k">class</span> <span class="nc">UPickupTarget</span> <span class="o">:</span> <span class="k">public</span> <span class="n">UInterface</span> <span class="p">{</span> <span class="n">GENERATED_BODY</span><span class="p">()</span> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="k">class</span> <span class="nc">IPickupTarget</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">GENERATED_BODY</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"><span class="k">public</span><span class="o">:</span>
</span></span><span class="line"><span class="cl">    <span class="n">UFUNCTION</span><span class="p">(</span><span class="n">BlueprintNativeEvent</span><span class="p">,</span> <span class="n">Category</span> <span class="o">=</span> <span class="s">&#34;Probe&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">    <span class="kt">void</span> <span class="n">OnPicked</span><span class="p">();</span>
</span></span><span class="line"><span class="cl"><span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1">// Control group: native implementation.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">UCLASS</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"><span class="k">class</span> <span class="nc">ANativePickup</span> <span class="o">:</span> <span class="k">public</span> <span class="n">AActor</span><span class="p">,</span> <span class="k">public</span> <span class="n">IPickupTarget</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">GENERATED_BODY</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"><span class="k">public</span><span class="o">:</span>
</span></span><span class="line"><span class="cl">    <span class="k">virtual</span> <span class="kt">void</span> <span class="n">OnPicked_Implementation</span><span class="p">()</span> <span class="k">override</span>
</span></span><span class="line"><span class="cl">    <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="n">UE_LOG</span><span class="p">(</span><span class="n">LogTemp</span><span class="p">,</span> <span class="n">Warning</span><span class="p">,</span> <span class="n">TEXT</span><span class="p">(</span><span class="s">&#34;[probe] OnPicked from C++&#34;</span><span class="p">));</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">UCLASS</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"><span class="k">class</span> <span class="nc">UInterfaceProbe</span> <span class="o">:</span> <span class="k">public</span> <span class="n">UBlueprintFunctionLibrary</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">GENERATED_BODY</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"><span class="k">public</span><span class="o">:</span>
</span></span><span class="line"><span class="cl">    <span class="n">UFUNCTION</span><span class="p">(</span><span class="n">BlueprintCallable</span><span class="p">,</span> <span class="n">Category</span> <span class="o">=</span> <span class="s">&#34;Probe&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">    <span class="k">static</span> <span class="kt">void</span> <span class="n">Probe</span><span class="p">(</span><span class="n">UObject</span><span class="o">*</span> <span class="n">Obj</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kt">void</span> <span class="n">UInterfaceProbe</span><span class="o">::</span><span class="n">Probe</span><span class="p">(</span><span class="n">UObject</span><span class="o">*</span> <span class="n">Obj</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">Obj</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">    <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="k">return</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">    <span class="k">const</span> <span class="kt">bool</span> <span class="n">bImplements</span> <span class="o">=</span> <span class="n">Obj</span><span class="o">-&gt;</span><span class="n">GetClass</span><span class="p">()</span><span class="o">-&gt;</span><span class="n">ImplementsInterface</span><span class="p">(</span><span class="n">UPickupTarget</span><span class="o">::</span><span class="n">StaticClass</span><span class="p">());</span>
</span></span><span class="line"><span class="cl">    <span class="n">IPickupTarget</span><span class="o">*</span> <span class="n">AsInterface</span> <span class="o">=</span> <span class="n">Cast</span><span class="o">&lt;</span><span class="n">IPickupTarget</span><span class="o">&gt;</span><span class="p">(</span><span class="n">Obj</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">    <span class="kt">void</span><span class="o">*</span> <span class="n">NativeActor</span> <span class="o">=</span> <span class="n">Obj</span><span class="o">-&gt;</span><span class="n">GetNativeInterfaceAddress</span><span class="p">(</span><span class="n">UPickupTarget</span><span class="o">::</span><span class="n">StaticClass</span><span class="p">());</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">    <span class="n">UE_LOG</span><span class="p">(</span><span class="n">LogTemp</span><span class="p">,</span> <span class="n">Warning</span><span class="p">,</span> <span class="n">TEXT</span><span class="p">(</span><span class="s">&#34;[probe] %s | Implements=%s | Cast=%s | NativeActor=%s&#34;</span><span class="p">),</span>
</span></span><span class="line"><span class="cl">        <span class="o">*</span><span class="n">Obj</span><span class="o">-&gt;</span><span class="n">GetClass</span><span class="p">()</span><span class="o">-&gt;</span><span class="n">GetName</span><span class="p">(),</span>
</span></span><span class="line"><span class="cl">        <span class="n">bImplements</span> <span class="o">?</span> <span class="n">TEXT</span><span class="p">(</span><span class="s">&#34;true&#34;</span><span class="p">)</span> <span class="o">:</span> <span class="n">TEXT</span><span class="p">(</span><span class="s">&#34;false&#34;</span><span class="p">),</span>
</span></span><span class="line"><span class="cl">        <span class="n">AsInterface</span> <span class="o">?</span> <span class="n">TEXT</span><span class="p">(</span><span class="s">&#34;ptr&#34;</span><span class="p">)</span> <span class="o">:</span> <span class="n">TEXT</span><span class="p">(</span><span class="s">&#34;NULL&#34;</span><span class="p">),</span>
</span></span><span class="line"><span class="cl">        <span class="n">NativeActor</span> <span class="o">?</span> <span class="n">TEXT</span><span class="p">(</span><span class="s">&#34;ptr&#34;</span><span class="p">)</span> <span class="o">:</span> <span class="n">TEXT</span><span class="p">(</span><span class="s">&#34;NULL&#34;</span><span class="p">));</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">    <span class="k">if</span> <span class="p">(</span><span class="n">bImplements</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">    <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="n">IPickupTarget</span><span class="o">::</span><span class="n">Execute_OnPicked</span><span class="p">(</span><span class="n">Obj</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div></div>
<p>The second implementation of the same interface is created in the editor: a Blueprint Actor class named <code>BP_BlueprintPickup</code>, with the <code>Pickup Target</code> interface added under Class Settings and an <code>On Picked</code> event that prints <code>[probe] OnPicked from BP</code>.</p>
<figure class="bp-embed">
  <div class="bp-embed__canvas" data-bp-src="/blueprints/interface-cast-bp-pickup-event.txt" data-bp-height="340"></div>
  <noscript>
    <p class="bp-embed__fallback">Viewing the graph requires JavaScript.</p>
    <a class="bp-embed__download" href="/blueprints/interface-cast-bp-pickup-event.txt" download>Download Blueprint graph (.txt)</a>
  </noscript><figcaption class="bp-embed__caption">The BP_BlueprintPickup event graph. This On Picked implementation does not exist in any C&#43;&#43; file, and it is what makes the class&#39;s entry in UClass::Interfaces carry bImplementedByK2 = true.</figcaption></figure>
<p>The Level Blueprint of an empty map drives the test. <code>NativePickup</code> is spawned in <code>BeginPlay</code>. <code>BP_BlueprintPickup</code> is placed in the level and retrieved with <code>Get Actor of Class</code>. Both objects pass through the same <code>Probe</code> along a single execution chain:</p>
<figure class="bp-embed">
  <div class="bp-embed__canvas" data-bp-src="/blueprints/interface-cast-probe-beginplay.txt" data-bp-height="460"></div>
  <noscript>
    <p class="bp-embed__fallback">Viewing the graph requires JavaScript.</p>
    <a class="bp-embed__download" href="/blueprints/interface-cast-probe-beginplay.txt" download>Download Blueprint graph (.txt)</a>
  </noscript><figcaption class="bp-embed__caption">Level Blueprint of the test map. One BeginPlay, two actors, the same Probe function. The test compares native and Blueprint interface implementations.</figcaption></figure>
<p>The log from that run:</p>
<div class="highlight" data-lang="log">
  <button type="button" class="code-copy" data-code-copy data-label="Copy" data-copied="Copied!" aria-label="Copy code to clipboard">Copy</button><pre tabindex="0" class="ue-log"><code><span class="ue-log__line ue-log__line--warning"><span class="ue-log__cat">LogTemp</span>: <span class="ue-log__sev ue-log__sev--warning">Warning</span>: <span class="ue-log__msg">[probe] NativePickup | Implements=true | Cast=ptr | NativeActor=ptr</span>
</span><span class="ue-log__line ue-log__line--warning"><span class="ue-log__cat">LogTemp</span>: <span class="ue-log__sev ue-log__sev--warning">Warning</span>: <span class="ue-log__msg">[probe] OnPicked from C++</span>
</span><span class="ue-log__line ue-log__line--warning"><span class="ue-log__cat">LogTemp</span>: <span class="ue-log__sev ue-log__sev--warning">Warning</span>: <span class="ue-log__msg">[probe] BP_BlueprintPickup_C | Implements=true | Cast=NULL | NativeActor=NULL</span>
</span><span class="ue-log__line"><span class="ue-log__cat">LogBlueprintUserMessages</span>: <span class="ue-log__msg">[probe] OnPicked from BP</span>
</span></code></pre>
</div>
<p>In the third line, <code>Implements=true</code> sits next to <code>Cast=NULL</code> for the same object in the same call. The fourth line shows <code>Execute_</code> invoking the implementation despite the <code>NULL</code>. The <code>LogBlueprintUserMessages</code> category confirms that the call landed in the Blueprint graph rather than the native fallback.</p>
<p>The first two lines are the control group. For a native implementation, all three readings agree and the cast works. The comparison focuses on where the interface implementation comes from.</p>
<h2 id="limits">Limits</h2>
<p>An interface class declared in Blueprint rather than in C++ — that is, one without <code>CLASS_Native</code> — behaves differently. For such an interface, <code>GetInterfaceAddress</code> never enters the loop over <code>Interfaces</code>. It returns <code>this</code>, provided <code>ImplementsInterface</code> is true. That is a separate branch of the same function in <code>Engine/Source/Runtime/CoreUObject/Private/UObject/UObjectBaseUtility.cpp</code>.</p>
<div class="callout callout--warning">
  <div class="callout__title">Warning</div>
  <code>CastChecked&lt;IMyInterface&gt;</code> does not make this pattern safe. It only changes where the failure occurs. With <code>DO_CHECK</code> enabled, it raises a fatal error, which is the behavior you want. In a build without <code>DO_CHECK</code>, the unchecked definition of <code>CastChecked</code> in <code>Casts.h</code> takes over and returns whatever <code>GetInterfaceAddress</code> gives it, without any check. That definition is itself marked <code>FUNCTION_NON_NULL_RETURN</code>, so it promises the caller a non-null pointer while potentially handing back <code>nullptr</code>. On that basis, the compiler is free to remove null checks at the call site. The behavior becomes least predictable in exactly the configuration where it is hardest to diagnose.
</div>

<p>This also has consequences for testing. A test built entirely from C++ classes will never catch the problem. Every implementation is native, <code>bImplementedByK2</code> is <code>false</code> everywhere, and the cast works every time. You can see that in the first two lines of the log above, where the control group passes. A test must include a Blueprint that implements the interface; otherwise, it exercises only the variant that was already correct.</p>
<p>As for the limits of the evidence: the mechanism comes from reading the UE 5.7 source (<code>UObjectBaseUtility.cpp</code>, <code>Class.cpp</code>, <code>Casts.h</code>, and the UHT generator) and was confirmed by one run in the editor on the same version. I have not checked whether <code>PointerOffset</code> and the <code>bImplementedByK2</code> filter behave the same way in older engine branches.</p>
<h2 id="sources">Sources</h2>
<ul>
<li><code>UObjectBaseUtility::GetInterfaceAddress</code>, <code>GetNativeInterfaceAddress</code> — <code>Engine/Source/Runtime/CoreUObject/Private/UObject/UObjectBaseUtility.cpp</code></li>
<li><code>UClass::ImplementsInterface</code> — <code>Engine/Source/Runtime/CoreUObject/Private/UObject/Class.cpp</code></li>
<li><code>Cast</code> / <code>CastChecked</code> for interfaces — <code>Engine/Source/Runtime/CoreUObject/Public/Templates/Casts.h</code></li>
<li><code>Execute_</code> generation — <code>Engine/Source/Programs/Shared/EpicGames.UHT/Exporters/CodeGen/UhtHeaderCodeGeneratorCppFile.cs</code>, <code>AppendInterfaceCallFunction</code></li>
<li><a href="https://dev.epicgames.com/documentation/en-us/unreal-engine/interfaces-in-unreal-engine" data-external rel="noopener" target="_blank">Unreal Docs: Interfaces</a> — the official description of <code>UINTERFACE</code> and <code>Execute_</code> calls</li>
</ul>
]]></content:encoded>
      
    </item>
    
    <item>
      <title>StillCooking_Tools</title>
      <link>https://stillcooking.dev/en/products/stillcooking-tools/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid isPermaLink="true">https://stillcooking.dev/en/products/stillcooking-tools/</guid>
      <description>A collection of small, reusable Unreal Engine tools — base classes, helpers, and routine operations.</description>
      <content:encoded><![CDATA[<p>StillCooking_Tools is a grab-bag of small, reusable Unreal Engine utilities — base classes,
helpers and common operations that are useful across unrelated projects, kept in one place with
one version instead of being copied from project to project.</p>
<p>It is deliberately not a framework: every entry stands on its own, so you can take one class or
one Blueprint node and ignore the rest. Nothing here depends on anything outside the engine.
Inside: <code>USCTickableObject</code>, a <code>UObject</code> that ticks every frame without being an Actor or a
Component; a console command registry whose commands have Blueprint bodies; four Flow nodes —
<strong>For Each Index With Delay</strong>, <strong>For Each Index Per Tick</strong>, <strong>Do For Duration</strong> and
<strong>Wait Until</strong>; and <strong>Print String Formatted</strong>, a <code>Print String</code> whose <code>{Placeholders}</code> become
pins. The C++ cores under the Flow nodes are usable directly.</p>
<h2 id="limits-worth-knowing-up-front">Limits worth knowing up front</h2>
<ul>
<li><strong>A C++ project is required.</strong> The plugin is distributed as source and compiled together with
your project, so a Blueprint-only project will not build it.</li>
<li><strong>Two entries are development-only.</strong> The console command registry compiles its registration
out of Shipping, and <code>Print String Formatted</code> is compiled out of Shipping and Test builds.</li>
<li><strong>The C++ layer under the Flow nodes is EXPERIMENTAL.</strong> The Blueprint nodes are stable; the
<code>FSCFlow*</code> classes under them may change shape without a major version bump.</li>
<li><strong>Nothing replicates.</strong> No entry knows about the network.</li>
<li><strong>Game Thread only.</strong> Nothing in the plugin is thread-safe; calls from other threads are
unsupported.</li>
</ul>
<p>The whole list: <a href="/en/products/stillcooking-tools/docs/advanced/limits-and-threading/">Limits</a>.</p>
<p>The plugin is free, distributed as C++ source on GitHub under the MIT license.</p>
]]></content:encoded>
      
    </item>
    
  </channel>
</rss>
