What is CDO?

CDO is Class Default Object, it’s a master copy of object for specific class contained in reflection system which in this case it’s contained in class representing the class which is UClass. CDO contains object defaults and make them accessible very easily since C++ don’t have such a feature. It is also used to hold default values of variables in virtual classes created from blueprints for example.

CDO is created when engine is initialized when it generates UClass objects for each class, then it naturally executes constructor setting default variables. Thats also reason why you should not use objects or gameplay code in constructor, because constructor is executed early in engine initiation stage where most objects don’t exist, not to mention level is most likely won’t be even loaded at that point. You should use different start up events which both UObject and AActor contains for many stages of it’s creation process, you can read about those here:

You can access CDO of each class via this function in UClass of specific class, starting 4.9 you will also able to access defaults from CDO in blueprint too (in more protected way of corse):

So in short, because of this setup, constructor can be only used for defaults that will be contained in CDO

19 Likes