Why can't my ActorComponent be dragged/added onto the default ACharacter?

I made an abstract class IMorpheme::UActorComponent, which only has two lines different from default- the

UCLASS(abstract) specifier and a virtual function declaration for child classes to override. However, when I try to add a child of this component onto my ACharacter, either through manually dragging & dropping or through the character’s AddComponent button, it doesn’t allow itself to be added. Is there any way I can inherit from an abstract UActorComponent and still add it to actors like an ordinary component?

.h, if it’s relevant::

UCLASS( ClassGroup=(Custom), abstract )
class CODEPROJECT_API UIMorpheme : public UActorComponent
{
	GENERATED_BODY()

public:	
	// Sets default values for this component's properties
	UIMorpheme();

	virtual void Attack() { check(0 && "You must override this"); };
//no original code past this point
}

What do you mean by ‘add a child of this component’? Have you inherited another component class from UIMorpheme in c++, which you’re trying to add? If so, post the code for that class too.

I have yes, sorry for the confusion- the complete chain goes UActorComponent::IMorpheme::IMorphemeVerb::IMorphemeAttack. IMorpheme is abstract, IMorphemeVerb is mostly empty function nubs with some action-specific stuff, and IMorphemeAttack is what I want to actually drag onto an AActor. A manager class grabs a reference to every IMorpheme on the actor, and runs

IMorphemeVerb.h:

#pragma once

#include "IMorpheme.h"
#include "Engine.h"
#include "IMorphemeVerb.generated.h"

/**
 * 
 */
UCLASS()
class CODEPROJECT_API UIMorphemeVerb : public UIMorpheme
{
	GENERATED_BODY()
	public:
			void Attack();
	
	
};

IMorphemeVerb.cpp:

#include “CodeProject.h”
#include “IMorphemeVerb.h”

void UIMorphemeVerb::Attack(){
//No functionality
}

IMorphemeAttack.h:

UCLASS()
class CODEPROJECT_API UMVAttack : public UIMorphemeVerb
{
	GENERATED_BODY()
	
public:
	void Attack() override;
	
};

IMorphemeAttack.cpp:

#include "CodeProject.h"
#include "IMorphemeAttack.h"




void IMorphemeAttack::Attack(){
	Super::Attack();
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Attack has been registered and made!"));
}

It’s a while since I looked into this, but I think you need to add the following specifiers to whichever components you want to add in the editor (so to UMVAttack in this case):

UCLASS(EditInlineNew, Meta = (BlueprintSpawnableComponent))

I don’t remember off hand if they’re both required, or if they’re inherited by derived classes, but it won’t do any harm to add both to all component classes you want to be able to instantiate.

That did the trick!! Thank you very much :slight_smile: