How do I spawn the blueprint of a component in code?

If I have a UActorComponent child named UTalk, I can add it to an actor in code with this:

UTalk* mySpeechComponent;
UTalk= CreateDefaultSubobject<UTalk>(FName(TEXT("Dialogue")));

That having been said, if I create a blueprint of the component, let’s say BP_Talk, how do I spawn that blueprint in code? Substituting the name of the blueprint for the name of the class doesn’t work.

Oh hey, thank you! :slight_smile:

in my object header:

	UPROPERTY(EditDefaultsOnly, Category = Projectile, meta = (AllowPrivateAccess = "true"))
		TSubclassOf<class ARedCobraProjectile> BulletClass;

in my object CPP

	static ConstructorHelpers::FObjectFinder<UBlueprint> Playerbullet1Blueprint(TEXT("Blueprint'/Game/blueprint/PlayerWep1.PlayerWep1'"));

	//BulletClass = NULL;

	if (Playerbullet1Blueprint.Succeeded())
	{
		BulletClass = (UClass*)Playerbullet1Blueprint.Object->GeneratedClass;

	}

in my tick :

    FVector sockloc = gunComponent->GetSocketLocation("gunsock");
    	FRotator sockrot = gunComponent->GetSocketRotation("gunsock");
    	FActorSpawnParameters SpawnParam;
    
    	SpawnParam.Owner = this;
    	SpawnParam.Instigator = Instigator;
    
ARedCobraProjectile *SpawnBullet = World->SpawnActor(BulletClass, sockloc, sockrot);

switch ARedCobraProjectile with whatever class your blueprint is :slight_smile:

np, let me know if you have any issues!