Attach a mesh to an actor in C++

Hi,

I have a quick question.

Is it possible to create your own mesh in C++ and attach it to an actor as a component.

I have tried the following tutorial Procedural Mesh Component in C++:Getting Started

and cannot get it to work.

Could some one please give me some advice

Thanks,

Hey CJD22-

If you create a UStaticMeshComponent* MyPtr pointer in the header file, you can then use MyPtr = CreateDefaultSubobject < UStaticMeshComponent> (TEXT("FriendlyName")); in the constructor to create a static mesh component. Once the component has been created you can assign a mesh to it inside of a blueprint or by using a ConstructorHelpers::FObjectFinder< UStaticMeshComponent> MeshRef("Path/to/mesh/asset") function to get a reference to your mesh asset and assign it in code using MyPtr->SetStaticMesh(MeshRef); The best way to get the reference to the asset is to right click on it in the content browser and choose “Copy Reference”.

Cheers