Explaining components initialization functions flow..

When you create a BP class you usually get:

Archetype Class - this is a “skeleton” of your C++ Class + Generated Code (Unreal’s Reflection System)
Default Object - this is the “generated class” the engine creates every time you run it, there’s always a “Class Default Object” or “CDO”; This is where you’ll see “GEN_VARIABLE” thingies.
Instanced Object - this will “spawn” in game world and copy default values from CDO once created (expose on spawn stuff, etc).

So the code you’ve created there is actually running on at least three places at same time.
You can easily check which “version” of your object you’re dealing with using something like:



MyObject->HasAnyFlags( RF_ClassDefaultObject | RF_ArchetypeObject );


If that is *true *that means the code isn’t running on an actual instance of an object spawned in the game world.

2 Likes