# Attach a mesh to an actor in C++

**URL:** <https://forums.unrealengine.com/t/attach-a-mesh-to-an-actor-in-c/369114>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [September 2, 2016, 1:46pm UTC](https://forums.unrealengine.com/t/attach-a-mesh-to-an-actor-in-c/369114 "2016-09-02T13:46:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_4b3027c8](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4b3027c8](https://forums.unrealengine.com/u/anonymous_user_4b3027c8)\
**Post date:** [September 2, 2016, 1:46pm UTC](https://forums.unrealengine.com/t/attach-a-mesh-to-an-actor-in-c/369114/1 "2016-09-02T13:46:25Z")

</div>

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

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

and cannot get it to work.

Could some one please give me some advice

Thanks,

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [September 2, 2016, 3:55pm UTC](https://forums.unrealengine.com/t/attach-a-mesh-to-an-actor-in-c/369114/2 "2016-09-02T15:55:05Z")

</div>

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
