Hey there,
So I have a class here that spawns my UE4 ship.
AFlightPawn::AFlightPawn(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
struct FConstructorStatics
{
ConstructorHelpers::FObjectFinderOptional<UStaticMesh>ShipMesh;
FConstructorStatics() : ShipMesh(TEXT("/Game/Ships/Engineer.Engineer")){}
};
static FConstructorStatics ConstructorStatics;
ShipMeshComp = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("ShipMesh"));
ShipMeshComp->SetStaticMesh(ConstructorStatics.ShipMesh.Get());
RootComponent = ShipMeshComp;
The problem is that the static mesh in my game/ships folder is exactly that, just a static mesh. I have a Blueprint version of this ship in the blueprint folder that I would like to spawn instead.
I read another post on here and tried changing the contructor struct to this:
struct FConstructorStatics
{
ConstructorHelpers::FObjectFinderOptional<UBlueprint>ShipMesh;
FConstructorStatics() : ShipMesh(TEXT("Blueprint'/Game/Blueprints/Engineer.Engineer'")){}
};
The problem is that just below that I have
static FConstructorStatics ConstructorStatics;
ShipMeshComp = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("ShipMesh"));
ShipMeshComp->SetStaticMesh(ConstructorStatics.ShipMesh.Get());
RootComponent = ShipMeshComp;
where I get the error that SetStaticMesh is for static meshes now and not for blueprints, which I’m setting above.
So my question is how can I spawn a blueprint class of my ship in C++?
Thanks!