Created a class based on Actor, I’m adding a UStaticMeshComponent, setting as RootComponent and spawning the actor in game.
If I pause and examine the actor, the static mesh component is ‘native’ and doesn’t show any details. If I then create a Blueprint based on my actor it looks like this:
Is the lack of details/components because this is a ‘native’ static mesh component? How do make my static mesh configurable? My next step is to add a material to the mesh, but looks like something is wrong.
Code as follows, class is called BlockBase.
.h
UCLASS()
class ABlockBase : public AActor
{
GENERATED_UCLASS_BODY()
TSubobjectPtr<UStaticMeshComponent> myStaticMeshComponent;
UStaticMesh * myStaticMeshObj;
};
.cpp
ABlockBase::ABlockBase(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
static ConstructorHelpers::FObjectFinder<UStaticMesh> myStaticMesh(TEXT("StaticMesh'/Game/Meshes/cube-no-back.cube-no-back'"));
myStaticMeshObj = myStaticMesh.Object;
// Create
myStaticMeshComponent = PCIP.CreateDefaultSubobject < UStaticMeshComponent >(this, TEXT("mySubObject"));
// set as root
RootComponent = myStaticMeshComponent;
// Set Mesh
myStaticMeshComponent->SetStaticMesh(myStaticMeshObj);
}