We took a Blueprint which loops through a SplineComponent’s points and adds StaticMeshComponents to the actor along those points and moved it into C++. Our C++ code, in an OnConstruction override, then mimicked the Blueprint: In a for-loop, we attempted numerous variations on the NewObject code block (creating, registering, etc), but in even the best case we only saw the final mesh appear.
Before we try and fix the last mesh appearing issue, I’d like to get Unreal’s suggested method of creating a child component in C++. The forums and answers seem to have a lot of people guessing and discussing the proper method, but I would rather not use the “magic” combination of creating and registering. We looked at the engine source to see what Create Static Mesh Component does, but that code seems to be heavily autogenerated and we couldn’t nail down where the actual creation takes place.
Is there an “Unreal approved” code block to create a child component?