I have a BP_FloorTile static mesh, want to spawn it at runtime in C++, C++ claims type is undefined however if I use the Blueprint SpawnActor function it shows BP_FloorTile available from the Class selection. Any ideas? I am a C++ engineer so I can’t stand drag and drop stuff, Thanks.
This is a bit unclear due to the name? Is it a blueprint or is it a static mesh. Assuming you do in fact mean a blueprint then you would declare a member
TSubclassOf<AActor> BPToSpawn;
Then in the constructor
#include "ConstructorHelpers.h"
AExample::Example()
{
// "/Game/" is the content folder
ConstructorHelpers::FClassFinder<AActor> BPFinder(TEXT("/Game/Path/To/BP"));
BPToSpawn = BPFinder.Class;
}