Selecting subclass of component in editor

My goal is to have a system where each Actor has a weapon component but the exact subclass of the UWeaponCompoment base class should be selectable in a blueprint created from the Actor class. Ideally, the default parameters of the component of the selected class should also be editable from within the blueprint.

I thought about creating the components within the blueprint and not within the C++ class and then search for components of certain classes in the C++ begin play method to establish references to the components. However, I thought there could be a more elegant way.

So my question is: Is there a more elegant way?

Hello, Praseodyl

In this situation, it will be more suitable to initialize your Weapon Component in constructor of your Actor like this:

Weapon = ObjectInitializer.CreateDefaultSubobject<UWeaponComponent>(this, TEXT("Weapon"));

After this, you can configure the component in the Blueprint of the Actor:


Hope this helped! Cheers!

Awesome, that sounds pretty much like what I am looking for. Thank you very much!

Any more details on how this could be done on the latest version of the engine?