'Template Mismatch during attachment' How to fix?

// Exact error
‘Template Mismatch during attachment. Attaching instanced component to template component.’
This is trying to attach a SphereCollision component to a Mesh Component

I have a projectile class. When trying to spawn it, I get the above error when running in debug. If I don’t run debug, it just spawns at the origin (0,0,0) and calling SetActorLocation doesn’t even affect it.

// The constructor for my projectile where I initialize it's components
AProjectile::AProjectile()
{
	ProjectileComponent = CreateDefaultSubobject<UProjectileComponent>("ProjectileComponent");
	SphereCollision = CreateDefaultSubobject<USphereComponent>("SphereCollision");
	
	if (SphereCollision)
	{
		RootComponent = SphereCollision;
		SphereCollision->SetSphereRadius(16, false);
		SphereCollision->AttachParent = nullptr;
	}
	if (ProjectileComponent)
	{
		ProjectileComponent->UpdatedComponent = SphereCollision;
	}
}

// Spawning a new projectile
Projectile = GetWorld()->SpawnActor<AProjectile>(AProjectile::StaticClass());

// Caster is an 'ACharacter'
Projectile->AttachRootComponentTo(Caster->GetMesh(), "Spell_Charge_Center", EAttachLocation::Type::SnapToTarget);

I tried calling SetTags() to set the tags to be the same as the MeshComponent’s tags. But that caused a different exception. What do I need to do in order to be able to attach this projectile to my Mesh? I know it can be done, because I have it working in Blueprints, I’m just trying to replicate it in C++

UPDATE: ProjectileComponent is a MovementComponent. I don’t think that is relevant in this case, but just in case…

Here is the header for Projectile…

UCLASS()
class GAME_API AProjectile : public AActor
{
	GENERATED_BODY()

public:
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Projectile")
	UProjectileComponent* ProjectileComponent;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Projectile")
	USphereComponent* SphereCollision;
};

I created a new project using the FPS Template. Added the above to the C++ and got the same exact result.

I managed to get it to work.

I was originally creating the projectile and attaching it inside of a Custom Component ( Ability System Component ). I copied the code over exactly the way it was into my player character and it worked.

So my assumption is, spawning actors or attaching components does not work when done so from within a component.

I managed to get it to work.

I was originally creating the projectile and attaching it inside of a Custom Component ( Ability System Component ). I copied the code over exactly the way it was into my player character and it worked.

So my assumption is, spawning actors or attaching components does not work when done so from within a component.