Hello, i73
Please note that CreateDefaultSubobject
is used to initialize a component or a subobject of an object, which is not exactly the same as spawning.
In your case, since you want the newly created object to be the Root component, please put the initialization object inside the constructor. This is logical since Root componentis essential for an object. Allowing to initialize it after the construction of an object would cause unexpected results.
Thus, if you want to create a component of your object, please use CreateDefaultSubobject
inside the constructor. If you want to create custom object, which is not supposed to be a component (for example create a Projectile when shooting), you can use SpawnActor
or NewObject
functions inside your custom methods.
Hope this helped!
Good luck!