How to make a root UShapeComponent that can properly change shapecomponent types per blueprint?

Trying to make a blueprint from a C++ class that can have different shape components as the root component. Say i want some blueprints subclassed from this to have BoxComponents, and some to have CapsuleComponents.
Seems like it should be easy.

This doesn’t work:

	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = Pickup)
		UPrimitiveComponent* CollisionComp;


UCapsuleComponent* cap = ObjectInitializer.CreateDefaultSubobject<UCapsuleComponent>(this, TEXT("CollisionComp"));
	cap->InitCapsuleSize(40.0f, 50.0f);
	CollisionComp = cap;
	RootComponent = CollisionComp;

What happens instead is that when while there is a widget in blueprint editor to change this shape to whatever i want, it simply doesn’t affect anything. The original shape still persists. what am i missing?

I know this is an old post, but i also want to know how to achieve that.
I tried removing the old component and adding a new one in the PostEditChangeProperty method, but the editor just crashes…

i opened a thread but also got no answer

Maybe this helps a bit:

I am also having this same issue as of 4.20.1; it seems there is a little bit of a workaround by using PostEditChangeProperty as done in that forum post to change the collider class at runtime and making the collider the root component every time a specified shape property changes, but this is still really messy, and it’s proven incredibly cumbursome and not very robust. Is there a good reason that we can’t use polymorphism and hold a default UShapeComponent* to some arbitrary UShapeComponent type and then swap other UShapeComponent types on a per class basis?.