How to let sub classes override components

I have a base class with a component of some abstract type. Then I have a subclass that needs to use a specific type.

Is this possible? So far the things I’ve tried resulted in runtime errors on startup.

Ah I figured it out!

Thanks to this question:

This was very confusing at first, but I ended up doing something like this:

AMyGamePhysicsItem::AMyGamePhysicsItem(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP.SetDefaultSubobjectClass<UStaticMeshComponent>(TEXT("WorldCollision")))
{	
	UStaticMeshComponent * WorldCollisionMesh = Cast<UStaticMeshComponent>(WorldCollision.Get());

	//make the world collision mesh not visible and set up all the networking and physics stuff
	if (WorldCollisionMesh)
	{
		WorldCollisionMesh->SetVisibility(false);
		WorldCollisionMesh->SetIsReplicated(true);
		WorldCollisionMesh->SetSimulatePhysics(true);
		WorldCollisionMesh->SetCollisionProfileName(TEXT("ItemWorld"));
		WorldCollisionMesh->bGenerateOverlapEvents = false;
		WorldCollisionMesh->GetBodyInstance()->SetInstanceNotifyRBCollision(true);		//generate hit events	
	}
}

PCIP.SetDefaultSubobjectClass returns a PCIP so you can string multiple SetDefaultSubobjectClass together inside the super constructor.

And if anyone’s wondering, this was code to have items affected by physics, like guns laying on the ground.

any clue on how to do this in 2018 and by inheriting in blueprints? i have opened a question here and would love to hear from you! UMeshComponent specification to Skeletal/Static in children - Programming & Scripting - Unreal Engine Forums