Help to spawn a blueprint from c++

Hi people, can you help me on my c++ program ?

Description:
When the player press R,G,B (KeyBoard keys) the program delete the current cube (Blueprint created from a c++ class),and we spawn the good cube blueprint.
My program:

PlCo.h

#pragma once

#include "InputCoreTypes.h"

#include "GreenCube.h"
#include "RedCube.h"
#include "BlueCube.h"

#include "GameFramework/PlayerController.h"
#include "PlCo.generated.h"

/**
 * 
 */
UCLASS()
class NEWPOSTEST_API APlCo : public APlayerController
{
	GENERATED_BODY()
	

	APlCo();

public:
	UFUNCTION()
		void InitKey();

	void SetRedCube();
	void SetGreenCube();
	void SetBlueCube();

	void SetActiveCube();


protected:
	UPROPERTY(BlueprintReadWrite, category = "Cube")
		int32 whichCube = 0;

	UPROPERTY(BlueprintReadWrite)
		TSubclassOf<ARedCube> RedCube;
	
	UPROPERTY(EditAnywhere, category = "TEST")
		TSubclassOf<ABlueCube> BlueCube;

	UPROPERTY(BlueprintReadWrite)
		TSubclassOf<AGreenCube> GreenCube;

};

PlCo.cpp

#include "NewPosTest.h"
#include "PlCo.h"



APlCo::APlCo()
{
	whichCube = 0;
	InitKey();

	//Define all cube BP /!\ Doesn't work /!\ 
	static ConstructorHelpers::FObjectFinder<UClass> RedCubeFinder(TEXT("Blueprint'/Game/NewPosTest/Content/RedCube_BP.RedCube_BP_C'"));
	RedCube = RedCubeFinder.Object;

	static ConstructorHelpers::FObjectFinder<UClass> BlueCubeFinder(TEXT("Blueprint'/Game/NewPosTest/Content/BlueCube_BP.BlueCube_PB_C'"));
	BlueCube = BlueCubeFinder.Object;

	static ConstructorHelpers::FObjectFinder<UClass> GreenCubeFinder(TEXT("Blueprint'/Game/NewPosTest/Content/GreenCube_BP.GreenCube_BP_C'"));
	GreenCube = GreenCubeFinder.Object;
}


void APlCo::InitKey()
{
	
	Super::SetupInputComponent();
	EnableInput(this);
	check(InputComponent);
	
	//Setup input
	InputComponent->BindKey(EKeys::R, IE_Released, this, &APlCo::SetRedCube);
	InputComponent->BindKey(EKeys::G, IE_Released, this, &APlCo::SetGreenCube);
	InputComponent->BindKey(EKeys::B, IE_Released, this, &APlCo::SetBlueCube);
	
}

//This function update the current cube 
void APlCo::SetRedCube()
{
	whichCube = 0;
	SetActiveCube();
}

void APlCo::SetGreenCube()
{
	whichCube = 1;
	SetActiveCube();
}

void APlCo::SetBlueCube()
{
	whichCube = 2;
	SetActiveCube();
}

void APlCo::SetActiveCube()
{

	//Delete Current cube BP
	//


	//We spawn the selected cube BP
	FVector tempLoc(0, 0, 0);
	FRotator temRot(0, 0, 0);

	if (whichCube == 0)
	{

		FActorSpawnParameters SpawnParams;
		SpawnParams.Owner = RedCube.GetDefaultObject();
		SpawnParams.Instigator = Instigator;

		GetWorld()->SpawnActor<ARedCube>(RedCube, tempLoc, temRot, SpawnParams);
	}

	else if (whichCube == 1)
	{
		

		FActorSpawnParameters SpawnParams;
		SpawnParams.Owner = GreenCube.GetDefaultObject();
		SpawnParams.Instigator = Instigator;

		GetWorld()->SpawnActor<AGreenCube>(GreenCube, tempLoc, temRot, SpawnParams);
	}
	else if (whichCube == 2)
	{


		FActorSpawnParameters SpawnParams;
		SpawnParams.Owner = BlueCube.GetDefaultObject();
		SpawnParams.Instigator = Instigator;

		GetWorld()->SpawnActor<ABlueCube>(BlueCube, tempLoc, temRot, SpawnParams);
	}

}

Info:
PlCo is a player controller class.

The input work perfectly.

I need to know how to spawn and unspawn the Cube BP.

Thanks.

EDIT : After the declaration of RedCubeFinder, I test it with .succeeded(). and it always return false.

Hi.

You can find an answer here

I’ve re edited my program :

    APlCo::APlCo()
    {
    	whichCube = 0;
    	InitKey();
    
    	//Define all cube BP /!\ Doesn't work /!\ 
    	static ConstructorHelpers::FObjectFinder<UBlueprint> RedCubeFinder(TEXT("Content/RedCube_BP"));
    	RedCube = (UClass*)RedCubeFinder.Object->GeneratedClass;
    
    	static ConstructorHelpers::FObjectFinder<UBlueprint> BlueCubeFinder(TEXT("Content/BlueCube_BP"));
    	BlueCube = (UClass*)BlueCubeFinder.Object->GeneratedClass;
    
    	static ConstructorHelpers::FObjectFinder<UBlueprint> GreenCubeFinder(TEXT("Content/GreenCube_BP"));
    	GreenCube = (UClass*)GreenCubeFinder.Object->GeneratedClass;
    }

// (and the rest is the same thing)

But now when I compile, unreal engine crash.

I resolve my problem :
APlCo::APlCo()
{
whichCube = 0;
InitKey();

	static ConstructorHelpers::FObjectFinder<UClass> RedCubeFinder(TEXT("Blueprint'/Game/RedCube_BP.RedCube_BP_C'"));
	if (RedCubeFinder.Succeeded() == true)
	{
		RedCube = RedCubeFinder.Object;
	}

	
}


void APlCo::InitKey()
{

	Super::SetupInputComponent();
	EnableInput(this);
	check(InputComponent);

	InputComponent->BindKey(EKeys::R, IE_Released, this, &APlCo::SetRedCube);
	InputComponent->BindKey(EKeys::G, IE_Released, this, &APlCo::SetGreenCube);
	InputComponent->BindKey(EKeys::B, IE_Released, this, &APlCo::SetBlueCube);

}

void APlCo::SetRedCube()
{
	whichCube = 0;
	SetActiveCube();
}

void APlCo::SetGreenCube()
{
	whichCube = 1;
	SetActiveCube();
}

void APlCo::SetBlueCube()
{
	whichCube = 2;
	SetActiveCube();
}

void APlCo::SetActiveCube()
{
	FVector tempLoc(0, 0, 0);
	FRotator temRot(0, 0, 0);

	if (whichCube == 0)
	{

		FActorSpawnParameters SpawnParams;

		GetWorld()->SpawnActor<ARedCube>(RedCube, tempLoc, temRot, SpawnParams);
	}
}