how can i add 'actor component' in run time?

i made ‘actor component’ type ‘FlyWithRocket’ ‘FlyWithWing’

and i met a beautiful rock in my adventure.

now i want to make it fly with mighty rocket power!! (seriously?)

how can add ‘flyWithRocket’ actor component to rock?

i tried with ‘construct object with class’ but it not works.

help!

I think you’ll have to do it with C++.
See here or here.

The code from link #2:

//Adds a UActorComponent Subclass, that is based on the passed in Class, and added to the Outer(Actor) object
 UActorComponent* UFSBlueprintFunctionLibrary::AddComponentByClass(TSubclassOf<UActorComponent> Class, UObject* Outer)
 {
     if (Class != nullptr && Outer != nullptr)
     {
         UActorComponent* Component = NewObject<UActorComponent>(Outer, *Class);
         if (Component != nullptr)
         {
             Component->RegisterComponent();
             return Component;
         }
         else
         {
             return nullptr;
         }
     }
 
     return nullptr;
 }