Hello, I 'm developing a scenecomponent with components attached inside in C++, which would be added on actors in outline, blueprint editor or during runtime. And here is my code:
It only works well on actors that are already existed in the world (in outline). For those in blueprint editor which are not spawned in the world, the USceneCaptureComponent2D disappeared.
in my code extrally? And where should I add this, in the construction function?
To say that in a word, what is the properly way to define my component? Especially for those that would be added in blueprint editor and also in runtime. Any tutorials? Thx!
I don’t have the direct answer but I’m willing to work through this with you as it’s of interest to me as well.
Generally speaking, any time you add a component dynamically (like you are), you should be calling RegisterComponent()…so yes.
I do not believe that will solve the issue right out of the gate but at the very least it should happen anyway. Start there and see if that changes the behavior.
One of the keys seems to be setting the CreationMethod variable on the newly created component to EComponentCreationMethod::Instance. That, coupled with a few other tricks mentioned in the final post should get us to a fully realized solution.