Creating an Actor Component via an Actor component

Hello i am trying to create an actor component from an actor component but nothing happens… I call these two lines in my Actor Component but nothing happends…

pathAnimationScript = CreateDefaultSubobject<UPathAnimation>(TEXT("TEST"));
owner->AddOwnedComponent(pathAnimationScript);

Any ideas??

Create DefaultSubObject can only be called in the classes constructor as it will serialize the component so it can be used with the editor.

If you want to create the components at run time, you will need to spawn them and attach them. There are many similar questions to this.

NewObject or CreateDefaultSubobject - Programming & Scripting - Unreal Engine Forums Can I dynamic CreateDefaultSubobject but not just in init function - Programming & Scripting - Unreal Engine Forums

Alex