Oh it’s that simple ?
I always create my components in the constructor through the CreateDefaultSubobject method.
So i always thought of components as some “special” objects that should be created only in the constructor and should pre-exist in the editor.
Never thought about managing them on the fly.
This opens a lot of possibilities, i’ll definitely have to play with that !
Thanks again for another very helpful and eye opening suggestion
Yes all NewObjects need to be managed more tightly so you need to destroy them if not needed.
Maybe you need to pass them to a TArray that is a uproperty if they are garbage collected. (I’ve only used NewObject for actors so not sure of their lifecycle)
Cool example, and that’s great news, this will definitely change the way i think about components.
I’ll make some tests on my side and will reorganize my code accordingly.
The life cycle in my case shouldn’t be too hard to handle: create everything at possession, and destroy everything at unpossession.
Again, thanks a ton for your time and help, very appreciated !